Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
魔术师Dix
Unity脚本自动生成工具:红丝线
提交
7572bbfb
Unity脚本自动生成工具:红丝线
项目概览
魔术师Dix
/
Unity脚本自动生成工具:红丝线
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Unity脚本自动生成工具:红丝线
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7572bbfb
编写于
11月 16, 2022
作者:
魔术师Dix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善脚本模板添加的功能;
上级
d244963e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
71 addition
and
69 deletion
+71
-69
Asset/LycianthesTemplateGroup.asset
Asset/LycianthesTemplateGroup.asset
+0
-14
Asset/LycianthesTemplateGroup.asset.meta
Asset/LycianthesTemplateGroup.asset.meta
+0
-8
Editor/LycianthesScriptCreator.cs
Editor/LycianthesScriptCreator.cs
+52
-45
Editor/LycianthesScriptWindow.cs
Editor/LycianthesScriptWindow.cs
+17
-0
Editor/LycianthesTemplateGroup.cs
Editor/LycianthesTemplateGroup.cs
+2
-2
未找到文件。
Asset/LycianthesTemplateGroup.asset
已删除
100644 → 0
浏览文件 @
d244963e
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!114
&11400000
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInstance
:
{
fileID
:
0
}
m_PrefabAsset
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
0
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
27752d2b796118843a746b67b337476c
,
type
:
3
}
m_Name
:
LycianthesTemplateGroup
m_EditorClassIdentifier
:
Asset/LycianthesTemplateGroup.asset.meta
已删除
100644 → 0
浏览文件 @
d244963e
fileFormatVersion: 2
guid: 78f67d703404d664fb1ea0ca4a7829c4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
Editor/LycianthesScriptCreator.cs
浏览文件 @
7572bbfb
...
...
@@ -8,6 +8,7 @@
*/
using
Sirenix.OdinInspector
;
using
System
;
using
System.Collections.Generic
;
using
UnityEditor
;
using
UnityEngine
;
...
...
@@ -76,49 +77,64 @@ namespace Lycianthes
[
Title
(
"预设脚本配置"
),
HideLabel
]
public
Dictionary
<
string
,
LycianthesScriptInfo
>
dictTemplate
=
new
Dictionary
<
string
,
LycianthesScriptInfo
>();
/// <summary>
/// 其他脚本的配置
/// </summary>
[
NonSerialized
]
private
List
<
LycianthesTemplateGroup
>
listOtherTemplate
=
new
List
<
LycianthesTemplateGroup
>();
public
void
ResetOtherTemplate
()
{
listOtherTemplate
?.
Clear
();
}
/// <summary>
/// 新建脚本
/// </summary>
[
Title
(
"脚本创建"
),
Button
(
"创建脚本"
,
ButtonSizes
.
Medium
)]
public
void
CreateNewScript
(
string
type
)
{
LycianthesScriptInfo
temp
;
if
(
dictTemplate
.
TryGetValue
(
type
,
out
temp
))
{
if
(
temp
==
null
)
return
;
LycianthesScriptInfo
temp
=
FindLycianthesScriptInfo
(
type
);
if
(
temp
==
null
)
return
;
//获取文件路径;
string
path
=
AssetDatabase
.
GetAssetPath
(
temp
.
Template
);
//创建脚本
CreateScriptByTemplate
.
Version
=
Version
;
CreateScriptByTemplate
.
Author
=
AuthorName
;
CreateScriptByTemplate
.
Company
=
Company
;
CreateScriptByTemplate
.
NameSpace
=
NameSpace
;
//删除前面的/Asset
string
curPath
=
temp
.
DefaultFolder
.
Substring
(
6
);
CreateScriptByTemplate
.
CreateSript
(
path
,
curPath
,
temp
.
DefaultName
);
}
//获取文件路径;
string
path
=
AssetDatabase
.
GetAssetPath
(
temp
.
Template
);
//创建脚本
CreateScriptByTemplate
.
Version
=
Version
;
CreateScriptByTemplate
.
Author
=
AuthorName
;
CreateScriptByTemplate
.
Company
=
Company
;
CreateScriptByTemplate
.
NameSpace
=
NameSpace
;
//删除前面的/Asset
string
curPath
=
temp
.
DefaultFolder
.
Substring
(
6
);
CreateScriptByTemplate
.
CreateSript
(
path
,
curPath
,
temp
.
DefaultName
);
public
LycianthesScriptInfo
FindLycianthesScriptInfo
(
string
type
)
{
LycianthesScriptInfo
ret
=
null
;
if
(
dictTemplate
.
TryGetValue
(
type
,
out
ret
))
return
ret
;
foreach
(
var
group
in
listOtherTemplate
)
{
if
(
group
.
dictTemplate
.
TryGetValue
(
type
,
out
ret
))
return
ret
;
}
#if DEBUG_LYCIANTHES
Debug
.
LogError
(
$"[Lycianthes] : 未找到对应脚本配置:
{
type
}
"
);
#endif
return
null
;
}
public
void
CreateNewScript
(
string
type
,
string
curPath
,
string
name
)
{
LycianthesScriptInfo
temp
;
if
(
dictTemplate
.
TryGetValue
(
type
,
out
temp
))
{
if
(
temp
==
null
)
return
;
//获取文件路径;
string
path
=
AssetDatabase
.
GetAssetPath
(
temp
.
Template
);
//创建脚本
CreateScriptByTemplate
.
Version
=
Version
;
CreateScriptByTemplate
.
Author
=
AuthorName
;
CreateScriptByTemplate
.
Company
=
Company
;
CreateScriptByTemplate
.
NameSpace
=
NameSpace
;
//删除前面的/Asset
CreateScriptByTemplate
.
CreateScriptNoChosse
(
path
,
curPath
,
name
);
}
LycianthesScriptInfo
temp
=
FindLycianthesScriptInfo
(
type
);
if
(
temp
==
null
)
return
;
//获取文件路径;
string
path
=
AssetDatabase
.
GetAssetPath
(
temp
.
Template
);
//创建脚本
CreateScriptByTemplate
.
Version
=
Version
;
CreateScriptByTemplate
.
Author
=
AuthorName
;
CreateScriptByTemplate
.
Company
=
Company
;
CreateScriptByTemplate
.
NameSpace
=
NameSpace
;
//删除前面的/Asset
CreateScriptByTemplate
.
CreateScriptNoChosse
(
path
,
curPath
,
name
);
}
/// <summary>
...
...
@@ -127,24 +143,12 @@ namespace Lycianthes
[
Button
(
"刷新"
)]
public
void
Refresh
()
{
AssetDatabase
.
Refresh
();
}
public
void
AddTemlateGroup
(
LycianthesTemplateGroup
group
)
{
if
(
group
==
null
)
return
;
foreach
(
var
item
in
group
.
dictTemplate
)
{
var
k
=
item
.
Key
;
var
v
=
item
.
Value
;
if
(
dictTemplate
.
ContainsKey
(
k
))
{
#if DEBUG_LYCIANTHES
Debug
.
LogError
(
$"[Lycianthes]: 已存在Key :
{
k
}
"
);
#endif
continue
;
}
dictTemplate
.
Add
(
k
,
v
);
}
if
(
listOtherTemplate
.
Contains
(
group
))
return
;
listOtherTemplate
.
Add
(
group
);
}
private
List
<
string
>
tempKeyList
=
new
List
<
string
>();
...
...
@@ -153,6 +157,9 @@ namespace Lycianthes
tempKeyList
.
Clear
();
foreach
(
var
item
in
dictTemplate
)
tempKeyList
.
Add
(
item
.
Key
);
foreach
(
var
item
in
listOtherTemplate
)
foreach
(
var
info
in
item
.
dictTemplate
)
tempKeyList
.
Add
(
info
.
Key
);
return
tempKeyList
;
}
...
...
Editor/LycianthesScriptWindow.cs
浏览文件 @
7572bbfb
...
...
@@ -45,6 +45,23 @@ namespace Lycianthes
window
.
TargetPath
=
GetCurrentSelectFolderPath
();
window
.
Version
=
PlayerSettings
.
bundleVersion
;
window
.
CompanyName
=
PlayerSettings
.
companyName
;
window
.
creator
.
ResetOtherTemplate
();
AutoLoadTemplateGroup
();
}
private
static
void
AutoLoadTemplateGroup
()
{
var
guids
=
AssetDatabase
.
FindAssets
(
"t:LycianthesTemplateGroup"
);
foreach
(
var
guid
in
guids
)
{
var
path
=
AssetDatabase
.
GUIDToAssetPath
(
guid
);
if
(
path
.
EndsWith
(
".asset"
))
{
var
group
=
AssetDatabase
.
LoadAssetAtPath
<
LycianthesTemplateGroup
>(
path
);
group
.
OnEnable
();
}
}
}
/// <summary>
...
...
Editor/LycianthesTemplateGroup.cs
浏览文件 @
7572bbfb
...
...
@@ -8,8 +8,8 @@
*/
using
Sirenix.OdinInspector
;
using
System
;
using
System.Collections.Generic
;
using
UnityEditor
;
using
UnityEngine
;
namespace
Lycianthes
...
...
@@ -24,7 +24,7 @@ namespace Lycianthes
[
Title
(
"预设脚本配置"
),
HideLabel
]
public
Dictionary
<
string
,
LycianthesScriptInfo
>
dictTemplate
=
new
Dictionary
<
string
,
LycianthesScriptInfo
>();
p
rivate
void
OnEnable
()
p
ublic
void
OnEnable
()
{
LycianthesScriptCreator
.
Instance
.
AddTemlateGroup
(
this
);
#if DEBUG_LYCIANTHES
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录