Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Emo_Tiny
ZFramework
提交
426374aa
Z
ZFramework
项目概览
Emo_Tiny
/
ZFramework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
ZFramework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
426374aa
编写于
7月 18, 2021
作者:
Emo_Tiny
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
全局对象管理中心
上级
cc66e218
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
265 addition
and
13 deletion
+265
-13
Assets/Plugins.meta
Assets/Plugins.meta
+0
-5
Assets/Script/Core.meta
Assets/Script/Core.meta
+1
-1
Assets/Script/Core/GlobalObjectManager.cs
Assets/Script/Core/GlobalObjectManager.cs
+62
-0
Assets/Script/Core/GlobalObjectManager.cs.meta
Assets/Script/Core/GlobalObjectManager.cs.meta
+11
-0
Assets/Script/Core/ResourceManager.cs
Assets/Script/Core/ResourceManager.cs
+7
-0
Assets/Script/Core/ResourceManager.cs.meta
Assets/Script/Core/ResourceManager.cs.meta
+0
-0
Assets/Script/Core/SingleMonoBehaviorObject.cs
Assets/Script/Core/SingleMonoBehaviorObject.cs
+103
-0
Assets/Script/Core/SingleMonoBehaviorObject.cs.meta
Assets/Script/Core/SingleMonoBehaviorObject.cs.meta
+11
-0
Assets/Script/Core/SingleObject.cs
Assets/Script/Core/SingleObject.cs
+59
-0
Assets/Script/Core/SingleObject.cs.meta
Assets/Script/Core/SingleObject.cs.meta
+11
-0
Assets/Script/ResourceMgr/LoadRS/ResourceLoadMgr.cs
Assets/Script/ResourceMgr/LoadRS/ResourceLoadMgr.cs
+0
-7
未找到文件。
Assets/Plugins.meta
已删除
100644 → 0
浏览文件 @
cc66e218
fileFormatVersion: 2
guid: f306c8709b26942118dae1897b73e0e7
folderAsset: yes
DefaultImporter:
userData:
Assets/Script/
ResourceMgr/UnLoadRS
.meta
→
Assets/Script/
Core
.meta
浏览文件 @
426374aa
fileFormatVersion: 2
guid: 3
7017dbb75686814ab009a8e02cc3726
guid: 3
50c7bd867107694fa403c4a21f12614
folderAsset: yes
DefaultImporter:
externalObjects: {}
...
...
Assets/Script/Core/GlobalObjectManager.cs
0 → 100644
浏览文件 @
426374aa
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
namespace
ZFramework.Core
{
public
class
GlobalObjectManager
{
private
static
Dictionary
<
string
,
GameObject
>
_gameObjectsDic
;
private
static
List
<
IGlobalObject
>
_objectList
;
public
static
void
Retain
(
GameObject
go
)
{
if
(
_gameObjectsDic
==
null
)
{
_gameObjectsDic
=
new
Dictionary
<
string
,
GameObject
>();
}
if
(!
_gameObjectsDic
.
ContainsKey
(
go
.
name
))
{
_gameObjectsDic
.
Add
(
go
.
name
,
go
);
if
(
Application
.
isPlaying
)
{
UnityEngine
.
Object
.
DontDestroyOnLoad
(
go
);
}
}
}
public
static
void
Retain
(
IGlobalObject
go
)
{
if
(
_objectList
==
null
)
{
_objectList
=
new
List
<
IGlobalObject
>();
}
_objectList
.
Add
(
go
);
}
public
static
void
Release
(
GameObject
go
)
{
if
(
_gameObjectsDic
!=
null
&&
_gameObjectsDic
.
ContainsKey
(
go
.
name
))
{
_gameObjectsDic
.
Remove
(
go
.
name
);
GameObject
.
Destroy
(
go
);
}
}
public
static
GameObject
GetGameObject
(
string
name
)
{
GameObject
go
=
null
;
if
(
_gameObjectsDic
!=
null
)
{
//return _gameObjectsDic[name];
_gameObjectsDic
.
TryGetValue
(
name
,
out
go
);
}
return
go
;
}
}
}
Assets/Script/Co
nfigMgr
.meta
→
Assets/Script/Co
re/GlobalObjectManager.cs
.meta
浏览文件 @
426374aa
fileFormatVersion: 2
guid: 5f9395a1e634c5b499d0f49bab3d6dd6
folderAsset: yes
DefaultImporter:
guid: 60fae4a4f20e9294d84b5c7d18697918
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Script/Core/ResourceManager.cs
0 → 100644
浏览文件 @
426374aa
namespace
ZFramework.Core
{
public
class
ResourceManager
{
}
}
\ No newline at end of file
Assets/Script/
ResourceMgr/LoadRS/ResourceLoadMg
r.cs.meta
→
Assets/Script/
Core/ResourceManage
r.cs.meta
浏览文件 @
426374aa
文件已移动
Assets/Script/Core/SingleMonoBehaviorObject.cs
0 → 100644
浏览文件 @
426374aa
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
namespace
ZFramework.Core
{
public
class
SingleMonoBehaviorObject
<
T
>
:
MonoBehaviour
where
T
:
SingleMonoBehaviorObject
<
T
>
{
private
static
T
_instance
;
private
void
Awake
()
{
if
(
CheckInstance
())
OnLoad
();
}
private
bool
CheckInstance
()
{
if
(
this
==
Instance
)
{
return
true
;
}
Destroy
(
gameObject
);
return
false
;
}
protected
virtual
void
OnLoad
()
{
}
protected
void
OnDestroy
()
{
if
(
_instance
==
this
)
{
_instance
=
null
;
}
}
/// <summary>
/// 判断对象是否有效
/// </summary>
public
static
bool
IsValid
{
get
{
return
_instance
!=
null
;
}
}
public
static
T
Active
()
{
return
Instance
;
}
/// <summary>
/// 实例化
/// </summary>
public
static
T
Instance
{
get
{
if
(
_instance
==
null
)
{
System
.
Type
type
=
typeof
(
T
);
string
name
=
type
.
Name
;
GameObject
go
=
GlobalObjectManager
.
GetGameObject
(
name
);
if
(
go
==
null
)
{
go
=
GameObject
.
Find
(
$"/
{
name
}
"
);
if
(
go
==
null
)
{
go
=
new
GameObject
(
name
);
go
.
transform
.
position
=
Vector3
.
one
;
}
GlobalObjectManager
.
Retain
(
go
);
}
if
(
go
!=
null
)
{
_instance
=
go
.
GetComponent
<
T
>();
if
(
_instance
==
null
)
{
_instance
=
go
.
AddComponent
<
T
>();
}
}
if
(
_instance
==
null
)
{
Debug
.
LogError
(
$"Can't create SingletonBehaviour<
{
typeof
(
T
)}
>"
);
}
}
return
_instance
;
}
}
}
}
Assets/Script/
ResourceMgr
.meta
→
Assets/Script/
Core/SingleMonoBehaviorObject.cs
.meta
浏览文件 @
426374aa
fileFormatVersion: 2
guid: c20df96b8dfc022479e6cb96c48e4535
folderAsset: yes
DefaultImporter:
guid: f90b1510b8a85d54599012e3d0d436fa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Script/Core/SingleObject.cs
0 → 100644
浏览文件 @
426374aa
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
ZFramework.Core
;
namespace
ZFramework.Core
{
public
interface
IGlobalObject
{
void
Active
();
void
Release
();
}
public
abstract
class
SingleObject
<
T
>
:
IGlobalObject
where
T
:
SingleObject
<
T
>,
new
()
{
protected
static
T
_instance
;
public
static
T
Instance
{
get
{
if
(
_instance
==
null
)
{
_instance
=
new
T
();
_instance
.
Init
();
GlobalObjectManager
.
Retain
(
_instance
);
}
return
_instance
;
}
}
public
static
bool
IsValid
{
get
{
return
_instance
!=
null
;
}
}
protected
virtual
void
Init
()
{
}
public
virtual
void
Active
()
{
}
public
virtual
void
Release
()
{
}
}
}
Assets/Script/
ResourceMgr/LoadRS
.meta
→
Assets/Script/
Core/SingleObject.cs
.meta
浏览文件 @
426374aa
fileFormatVersion: 2
guid: d235aef8e5460c544ab26d87a1bfd5ee
folderAsset: yes
DefaultImporter:
guid: 1663409355ffc3647842bd78629025c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Script/ResourceMgr/LoadRS/ResourceLoadMgr.cs
已删除
100644 → 0
浏览文件 @
cc66e218
namespace
Script.ResourceMgr.LoadRS
{
public
class
ResourceLoadMgr
{
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录