提交 de60ffc5 编写于 作者: 魔术师Dix's avatar 魔术师Dix

修改创建脚本的KV值设置,重新整理文件;

上级 53b2830b
......@@ -26,18 +26,12 @@ MonoBehaviour:
SerializationNodes:
- Name: dictTemplate
Entry: 7
Data: 0|System.Collections.Generic.Dictionary`2[[Lycianthes.E_ScriptType, Lycianthes],[Lycianthes.LycianthesScriptInfo,
Data: 0|System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[Lycianthes.LycianthesScriptInfo,
Lycianthes]], mscorlib
- Name: comparer
Entry: 7
Data: 1|System.Collections.Generic.EnumEqualityComparer`1[[Lycianthes.E_ScriptType,
Lycianthes]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
Data: 1|System.Collections.Generic.GenericEqualityComparer`1[[System.String,
mscorlib]], mscorlib
- Name:
Entry: 8
Data:
......@@ -48,8 +42,8 @@ MonoBehaviour:
Entry: 7
Data:
- Name: $k
Entry: 3
Data: 0
Entry: 1
Data: CSharpCommon
- Name: $v
Entry: 7
Data: 2|Lycianthes.LycianthesScriptInfo, Lycianthes
......@@ -58,10 +52,10 @@ MonoBehaviour:
Data: 0
- Name: DefaultName
Entry: 1
Data: Lycianthes_
Data: LycianthesCommon_
- Name: DefaultFolder
Entry: 1
Data: Assets/Scripts/Common
Data: Assets
- Name:
Entry: 8
Data:
......@@ -72,8 +66,8 @@ MonoBehaviour:
Entry: 7
Data:
- Name: $k
Entry: 3
Data: 1
Entry: 1
Data: CSharpScriptableObject
- Name: $v
Entry: 7
Data: 3|Lycianthes.LycianthesScriptInfo, Lycianthes
......@@ -82,10 +76,10 @@ MonoBehaviour:
Data: 1
- Name: DefaultName
Entry: 1
Data: Lycianthes_
Data: LycianthesScriptableObject_
- Name: DefaultFolder
Entry: 1
Data: Assets/Scripts
Data: Assets
- Name:
Entry: 8
Data:
......@@ -96,8 +90,8 @@ MonoBehaviour:
Entry: 7
Data:
- Name: $k
Entry: 3
Data: 2
Entry: 1
Data: CSharpMonoBehaviour
- Name: $v
Entry: 7
Data: 4|Lycianthes.LycianthesScriptInfo, Lycianthes
......@@ -106,10 +100,10 @@ MonoBehaviour:
Data: 2
- Name: DefaultName
Entry: 1
Data: Lycianthes_
Data: LycianthesMonoBehaviour_
- Name: DefaultFolder
Entry: 1
Data: Assets/Scripts/Core/System
Data: Assets
- Name:
Entry: 8
Data:
......@@ -122,7 +116,7 @@ MonoBehaviour:
- Name:
Entry: 8
Data:
Company: GYYX
Version: A.2.1
Company: Chief
Version: 1.0
AuthorName: Chief
NameSpace: Lycianthes
%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:
fileFormatVersion: 2
guid: 78f67d703404d664fb1ea0ca4a7829c4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
/*
*Copyright(C) 2020 by Chief All rights reserved.
*Unity版本:2019.4.8f1
*作者:Chief
*创建日期: 2020-08-17
*模块说明:
*版本: 1.0.0
*/
namespace Lycianthes
{
public enum E_ScriptType
{
/// <summary>
/// 通用
/// </summary>
Common,
/// <summary>
/// ScriptObject;
/// </summary>
ScriptObject,
/// <summary>
/// MonoBehaviour;
/// </summary>
MonoBehaviour,
}
}
......@@ -20,11 +20,22 @@ namespace Lycianthes
{
#region 自动获取配置方法
private static LycianthesScriptCreator _Instance;
public static LycianthesScriptCreator Instance
{
get
{
if (_Instance == null)
AutoLoadAsset();
return _Instance;
}
}
/// <summary>
/// 自动获取路径的方法;
/// </summary>
[InitializeOnLoadMethod]
private static void AutoSelectPath()
private static void AutoLoadAsset()
{
string assetName = "LycianthesScriptCreator";
string[] guids = AssetDatabase.FindAssets(assetName);
......@@ -35,13 +46,13 @@ namespace Lycianthes
if (path.EndsWith(".asset"))
{
LycianthesScriptWindow.AssetPath = path;
_Instance = AssetDatabase.LoadAssetAtPath<LycianthesScriptCreator>(path);
#if UNITY_EDITOR
Debug.Log($"[Lycianthes] : 配置路径{path}");
Debug.Log($"[Lycianthes] : 配置路径{path} |{_Instance}");
#endif
return;
}
}
Debug.LogError($"[Lycianthes] : 未找到目标资源:{assetName}");
}
......@@ -61,13 +72,13 @@ namespace Lycianthes
public string NameSpace = "RedPanda";
[Title("预设脚本配置"), HideLabel]
public Dictionary<E_ScriptType, LycianthesScriptInfo> dictTemplate = new Dictionary<E_ScriptType, LycianthesScriptInfo>();
public Dictionary<string, LycianthesScriptInfo> dictTemplate = new Dictionary<string, LycianthesScriptInfo>();
/// <summary>
/// 新建脚本
/// </summary>
[Title("脚本创建"), Button("创建脚本", ButtonSizes.Medium)]
public void CreateNewScript(E_ScriptType type)
public void CreateNewScript(string type)
{
LycianthesScriptInfo temp;
if (dictTemplate.TryGetValue(type, out temp))
......@@ -88,7 +99,7 @@ namespace Lycianthes
}
}
public void CreateNewScript(E_ScriptType type, string curPath, string name)
public void CreateNewScript(string type, string curPath, string name)
{
LycianthesScriptInfo temp;
if (dictTemplate.TryGetValue(type, out temp))
......@@ -114,6 +125,32 @@ 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))
{
Debug.LogError($"[Lycianthes]: 已存在Key : {k}");
continue;
}
dictTemplate.Add(k, v);
}
}
private List<string> tempKeyList = new List<string>();
public List<string> GetScriptTemplateKey()
{
tempKeyList.Clear();
foreach (var item in dictTemplate)
tempKeyList.Add(item.Key);
return tempKeyList;
}
}
}
\ No newline at end of file
......@@ -114,8 +114,10 @@ namespace Lycianthes
PlayerPrefs.SetString(KEY_USER_NAMESPACE, NameSpace);
}
[HideLabel, Title("脚本类型"), OnValueChanged("OnScriptTypeChanged"), EnumToggleButtons]
public E_ScriptType scriptType = E_ScriptType.Common;
[HideLabel, Title("脚本类型"), OnValueChanged("OnScriptTypeChanged")]
[ValueDropdown("GetScriptKey")]
public string scriptType = "CSharpCommon";
private List<string> GetScriptKey() { return creator.GetScriptTemplateKey(); }
[Title("保存位置"), Space(15)]
[LabelWidth(LABEL_WIDTH), LabelText("批量创建")]
......@@ -126,6 +128,7 @@ namespace Lycianthes
[HideIf("IsList")]
public string ScriptName = "";
[LabelText("脚本列表"), LabelWidth(LABEL_WIDTH), ShowIf("IsList")]
public List<string> ListScriptName = new List<string>();
......
/*
*Copyright(C) 2023 by Chief All rights reserved.
*Unity版本:2020.3.41f1c1
*作者:Chief
*创建日期: 2022-11-15
*模块说明:
*版本: 1.0
*/
using Sirenix.OdinInspector;
using System.Collections.Generic;
using UnityEngine;
namespace Lycianthes
{
/// <summary>
/// 自定义脚本模板组
/// </summary>
[CreateAssetMenu(fileName = "LycianthesTemplateGroup", menuName = "Lycianthes/自定义脚本模板组", order = 1)]
public class LycianthesTemplateGroup : SerializedScriptableObject
{
[Title("预设脚本配置"), HideLabel]
public Dictionary<string, LycianthesScriptInfo> dictTemplate = new Dictionary<string, LycianthesScriptInfo>();
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 9fa905ce86a1b2e46b745bbeafd38b94
guid: 27752d2b796118843a746b67b337476c
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册