Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
guo450212436
et
提交
e83b89d2
E
et
项目概览
guo450212436
/
et
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
et
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e83b89d2
编写于
6月 23, 2017
作者:
T
tanghai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
一般只能从hotfix层调用到mono层,尽量少从mono层调到脚本层
上级
56ff7d9f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
21 addition
and
177 deletion
+21
-177
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
+2
-4
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs.meta
...ssets/Scripts/Component/MessageDispatherComponent.cs.meta
+1
-1
Unity/Assets/Scripts/Component/ResourcesComponent.cs
Unity/Assets/Scripts/Component/ResourcesComponent.cs
+3
-11
Unity/Assets/Scripts/Entity/Scene.cs
Unity/Assets/Scripts/Entity/Scene.cs
+0
-2
Unity/Assets/Scripts/Init.cs
Unity/Assets/Scripts/Init.cs
+5
-5
Unity/Hotfix/Component/ResourcesComponent.cs
Unity/Hotfix/Component/ResourcesComponent.cs
+0
-145
Unity/Hotfix/Component/UIComponent.cs
Unity/Hotfix/Component/UIComponent.cs
+1
-1
Unity/Hotfix/Entity/Scene.cs
Unity/Hotfix/Entity/Scene.cs
+4
-2
Unity/Hotfix/Init.cs
Unity/Hotfix/Init.cs
+3
-2
Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs
Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs
+1
-2
Unity/Hotfix/Unity.Hotfix.csproj
Unity/Hotfix/Unity.Hotfix.csproj
+1
-2
未找到文件。
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs
浏览文件 @
e83b89d2
...
...
@@ -7,15 +7,13 @@ namespace Model
/// 消息分发组件
/// </summary>
[
ObjectEvent
(
EntityEventId
.
MessageDispatherComponent
)]
public
class
MessageDispatherComponent
:
Component
,
IAwake
<
AppType
>
,
ILoad
public
class
MessageDispatherComponent
:
Component
,
IAwake
,
ILoad
{
private
AppType
AppType
;
private
Dictionary
<
ushort
,
List
<
IInstanceMethod
>>
handlers
;
private
DoubleMap
<
ushort
,
Type
>
opcodeTypes
=
new
DoubleMap
<
ushort
,
Type
>();
public
void
Awake
(
AppType
appType
)
public
void
Awake
()
{
this
.
AppType
=
appType
;
this
.
Load
();
}
...
...
Unity/Assets/Scripts/Component/MessageDispatherComponent.cs.meta
浏览文件 @
e83b89d2
fileFormatVersion: 2
guid: 8e97599ee372f6f40aaa5e743851a74c
timeCreated: 1498
117781
timeCreated: 1498
200974
licenseType: Free
MonoImporter:
serializedVersion: 2
...
...
Unity/Assets/Scripts/Component/ResourcesComponent.cs
浏览文件 @
e83b89d2
...
...
@@ -99,17 +99,9 @@ namespace Model
{
// 异步load资源到内存cache住
UnityEngine
.
Object
[]
assets
;
AssetBundleLoaderAsync
assetBundleLoaderAsync
=
null
;
try
{
assetBundleLoaderAsync
=
new
AssetBundleLoaderAsync
(
assetBundle
);
assets
=
await
assetBundleLoaderAsync
.
LoadAllAssetsAsync
();
}
finally
{
assetBundleLoaderAsync
?.
Dispose
();
using
(
AssetBundleLoaderAsync
assetBundleLoaderAsync
=
new
AssetBundleLoaderAsync
(
assetBundle
))
{
assets
=
await
assetBundleLoaderAsync
.
LoadAllAssetsAsync
();
}
...
...
Unity/Assets/Scripts/Entity/Scene.cs
浏览文件 @
e83b89d2
...
...
@@ -21,8 +21,6 @@
public
string
Name
{
get
;
set
;
}
public
SceneType
SceneType
{
get
;
private
set
;
}
public
Scene
():
base
(
EntityType
.
Scene
)
{
}
...
...
Unity/Assets/Scripts/Init.cs
浏览文件 @
e83b89d2
...
...
@@ -34,7 +34,7 @@ namespace Model
this
.
RegisterDelegate
();
this
.
RegisterRedirection
();
IType
hotfixInitType
=
AppDomain
.
LoadedTypes
[
"Hotfix.
Hotfix
Init"
];
IType
hotfixInitType
=
AppDomain
.
LoadedTypes
[
"Hotfix.Init"
];
start
=
hotfixInitType
.
GetMethod
(
"Start"
,
0
);
update
=
hotfixInitType
.
GetMethod
(
"Update"
,
0
);
onApplicationQuit
=
hotfixInitType
.
GetMethod
(
"OnApplicationQuit"
,
0
);
...
...
@@ -50,9 +50,9 @@ namespace Model
private
void
Update
()
{
ObjectEvents
.
Instance
.
Update
();
this
.
AppDomain
.
Invoke
(
this
.
update
,
null
,
this
.
param0
);
ObjectEvents
.
Instance
.
Update
();
}
private
void
OnApplicationQuit
()
...
...
@@ -75,14 +75,14 @@ namespace Model
public
unsafe
void
RegisterRedirection
()
{
var
mi
=
typeof
(
Log
).
GetMethod
(
"Debug"
,
new
System
.
Type
[]
{
typeof
(
string
)
});
MethodInfo
mi
=
typeof
(
Log
).
GetMethod
(
"Debug"
,
new
Type
[]
{
typeof
(
string
)
});
this
.
AppDomain
.
RegisterCLRMethodRedirection
(
mi
,
ILRedirection
.
LogDebug
);
}
public
void
RegisterDelegate
()
{
AppDomain
.
DelegateManager
.
RegisterMethodDelegate
<
AChannel
,
System
.
Net
.
Sockets
.
SocketError
>();
AppDomain
.
DelegateManager
.
RegisterMethodDelegate
<
System
.
Byte
[],
System
.
Int32
,
System
.
Int32
>();
AppDomain
.
DelegateManager
.
RegisterMethodDelegate
<
byte
[],
int
,
int
>();
}
...
...
Unity/Hotfix/Component/ResourcesComponent.cs
已删除
100644 → 0
浏览文件 @
56ff7d9f
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
Model
;
using
UnityEngine
;
namespace
Hotfix
{
[
ObjectEvent
(
EntityEventId
.
ResourcesComponent
)]
public
class
ResourcesComponent
:
Component
{
public
static
AssetBundleManifest
AssetBundleManifestObject
{
get
;
set
;
}
private
readonly
Dictionary
<
string
,
UnityEngine
.
Object
>
resourceCache
=
new
Dictionary
<
string
,
UnityEngine
.
Object
>();
private
readonly
Dictionary
<
string
,
AssetBundle
>
bundleCaches
=
new
Dictionary
<
string
,
AssetBundle
>();
public
K
GetReference
<
K
>(
string
bundle
,
string
prefab
,
string
key
)
where
K
:
class
{
GameObject
gameObject
=
this
.
GetAsset
<
GameObject
>(
bundle
,
prefab
);
return
gameObject
.
GetComponent
<
ReferenceCollector
>().
Get
<
K
>(
key
);
}
public
K
GetAsset
<
K
>(
string
bundleName
,
string
prefab
)
where
K
:
class
{
string
path
=
$"
{
bundleName
}
.unity3d/
{
prefab
}
"
.
ToLower
();
UnityEngine
.
Object
resource
=
null
;
if
(
this
.
resourceCache
.
TryGetValue
(
path
,
out
resource
))
{
return
resource
as
K
;
}
if
(
Define
.
LoadResourceType
==
LoadResourceType
.
Async
)
{
if
(!
this
.
bundleCaches
.
ContainsKey
(
$"
{
bundleName
}
.unity3d"
.
ToLower
()))
{
return
null
;
}
throw
new
Exception
(
$"异步加载资源,资源不在resourceCache中:
{
bundleName
}
{
path
}
"
);
}
try
{
resource
=
ResourceHelper
.
LoadResource
(
bundleName
,
prefab
);
this
.
resourceCache
.
Add
(
path
,
resource
);
}
catch
(
Exception
e
)
{
throw
new
Exception
(
$"加载资源出错,输入路径:
{
path
}
"
,
e
);
}
return
resource
as
K
;
}
public
async
Task
DownloadAndCacheAsync
(
string
uri
,
string
assetBundleName
)
{
assetBundleName
=
(
assetBundleName
+
".unity3d"
).
ToLower
();
AssetBundle
assetBundle
;
// 异步下载资源
string
url
=
uri
+
"StreamingAssets/"
+
assetBundleName
;
int
count
=
0
;
while
(
true
)
{
WWWAsync
wwwAsync
=
null
;
try
{
++
count
;
if
(
count
>
1
)
{
await
Hotfix
.
Scene
.
GetComponent
<
TimerComponent
>().
WaitAsync
(
2000
);
}
if
(
this
.
Id
==
0
)
{
return
;
}
wwwAsync
=
new
WWWAsync
();
await
wwwAsync
.
LoadFromCacheOrDownload
(
url
,
ResourcesComponent
.
AssetBundleManifestObject
.
GetAssetBundleHash
(
assetBundleName
));
assetBundle
=
wwwAsync
.
www
.
assetBundle
;
break
;
}
catch
(
Exception
e
)
{
Log
.
Error
(
e
.
ToString
());
}
finally
{
wwwAsync
?.
Dispose
();
}
}
if
(!
assetBundle
.
isStreamedSceneAssetBundle
)
{
// 异步load资源到内存cache住
UnityEngine
.
Object
[]
assets
;
AssetBundleLoaderAsync
assetBundleLoaderAsync
=
null
;
try
{
assetBundleLoaderAsync
=
new
AssetBundleLoaderAsync
(
assetBundle
);
assets
=
await
assetBundleLoaderAsync
.
LoadAllAssetsAsync
();
}
finally
{
assetBundleLoaderAsync
?.
Dispose
();
}
foreach
(
UnityEngine
.
Object
asset
in
assets
)
{
string
path
=
$"
{
assetBundleName
}
/
{
asset
.
name
}
"
.
ToLower
();
this
.
resourceCache
[
path
]
=
asset
;
}
}
if
(
this
.
bundleCaches
.
ContainsKey
(
assetBundleName
))
{
throw
new
Exception
(
$"重复加载资源:
{
assetBundleName
}
"
);
}
this
.
bundleCaches
[
assetBundleName
]
=
assetBundle
;
}
public
override
void
Dispose
()
{
if
(
this
.
Id
==
0
)
{
return
;
}
base
.
Dispose
();
foreach
(
var
assetBundle
in
bundleCaches
)
{
assetBundle
.
Value
?.
Unload
(
true
);
}
}
}
}
\ No newline at end of file
Unity/Hotfix/Component/UIComponent.cs
浏览文件 @
e83b89d2
...
...
@@ -23,7 +23,7 @@ namespace Hotfix
this
.
params3
[
0
]
=
scene
;
this
.
params3
[
1
]
=
type
;
this
.
params3
[
2
]
=
parent
;
return
(
UI
)
Init
.
Instance
.
AppDomain
.
Invoke
(
this
.
methodInfo
,
this
.
instance
,
this
.
params3
);
return
(
UI
)
Model
.
Init
.
Instance
.
AppDomain
.
Invoke
(
this
.
methodInfo
,
this
.
instance
,
this
.
params3
);
}
}
...
...
Unity/Hotfix/Entity/Scene.cs
浏览文件 @
e83b89d2
...
...
@@ -19,9 +19,9 @@
{
public
Scene
Parent
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
Model
.
Scene
ModelScene
{
get
;
set
;
}
=
new
Model
.
Scene
();
public
SceneType
SceneType
{
get
;
private
set
;
}
public
string
Name
{
get
;
set
;
}
public
Scene
():
base
(
EntityType
.
Scene
)
{
...
...
@@ -39,6 +39,8 @@
}
base
.
Dispose
();
this
.
ModelScene
.
Dispose
();
}
}
}
\ No newline at end of file
Unity/Hotfix/
Hotfix
Init.cs
→
Unity/Hotfix/Init.cs
浏览文件 @
e83b89d2
...
...
@@ -3,13 +3,14 @@ using Model;
namespace
Hotfix
{
public
static
class
Hotfix
Init
public
static
class
Init
{
private
static
void
Start
()
{
try
{
Hotfix
.
Scene
.
AddComponent
<
ResourcesComponent
>();
Hotfix
.
Scene
.
ModelScene
.
AddComponent
<
NetOuterComponent
>();
Hotfix
.
Scene
.
ModelScene
.
AddComponent
<
ResourcesComponent
>();
Hotfix
.
Scene
.
AddComponent
<
UIComponent
>();
Hotfix
.
Scene
.
AddComponent
<
UnitComponent
>();
Hotfix
.
Scene
.
GetComponent
<
EventComponent
>().
Run
(
EventIdType
.
InitSceneStart
);
...
...
Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs
浏览文件 @
e83b89d2
using
Model
;
using
UnityEngine
;
using
Object
=
UnityEngine
.
Object
;
namespace
Hotfix
{
...
...
@@ -9,7 +8,7 @@ namespace Hotfix
{
public
UI
Create
(
Scene
scene
,
int
type
,
UI
parent
)
{
GameObject
bundleGameObject
=
scene
.
GetComponent
<
ResourcesComponent
>().
GetAsset
<
GameObject
>(
"uilobby"
,
"Lobby"
);
GameObject
bundleGameObject
=
scene
.
ModelScene
.
GetComponent
<
ResourcesComponent
>().
GetAsset
<
GameObject
>(
"uilobby"
,
"Lobby"
);
GameObject
lobby
=
UnityEngine
.
Object
.
Instantiate
(
bundleGameObject
);
lobby
.
layer
=
LayerMask
.
NameToLayer
(
LayerNames
.
UI
);
UI
ui
=
new
UI
(
scene
,
type
,
parent
,
lobby
);
...
...
Unity/Hotfix/Unity.Hotfix.csproj
浏览文件 @
e83b89d2
...
...
@@ -56,7 +56,7 @@
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Helper\JsonHelper.cs"
/>
<Compile
Include=
"
Hotfix
Init.cs"
/>
<Compile
Include=
"Init.cs"
/>
<Compile
Include=
"LitJson\IJsonWrapper.cs"
/>
<Compile
Include=
"LitJson\JsonData.cs"
/>
<Compile
Include=
"LitJson\JsonException.cs"
/>
...
...
@@ -71,7 +71,6 @@
<Compile
Include=
"Component\EventComponent.cs"
/>
<Compile
Include=
"Component\GameObjectComponent.cs"
/>
<Compile
Include=
"Component\KVComponent.cs"
/>
<Compile
Include=
"Component\ResourcesComponent.cs"
/>
<Compile
Include=
"Component\RobotComponent.cs"
/>
<Compile
Include=
"Component\TimeComponent.cs"
/>
<Compile
Include=
"Component\TimerComponent.cs"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录