1.修改文件后缀为rscript2.NewSubScript现在专用于创建简单对象
This commit is contained in:
@@ -184,7 +184,7 @@ namespace Demo.Game
|
||||
{
|
||||
while (MainConfig.Contains("root") == false)
|
||||
{
|
||||
string defaultRootPath = "root.cpp";
|
||||
string defaultRootPath = "root.rscript";
|
||||
if (content.IsCreateNewProject)
|
||||
{
|
||||
MainConfig["root"] = defaultRootPath;
|
||||
|
||||
@@ -468,13 +468,42 @@ namespace Demo
|
||||
callback?.Invoke(child);
|
||||
}
|
||||
|
||||
public ScriptableObject DoGenerateSubScript([In] string type, string name, [Opt] Action<ScriptableObject> callback)
|
||||
{
|
||||
// 判断类型是否合法
|
||||
if (DefaultInstantiate.GetScriptableObjectInstantiate().TryGetValue(type, out var creater) == false)
|
||||
{
|
||||
Debug.LogError($"{type} is not exist or {type}'s Instantiater is not valid", this);
|
||||
callback?.Invoke(null);
|
||||
return null;
|
||||
}
|
||||
// 生成对象
|
||||
var child = creater();
|
||||
child.ScriptName = name;
|
||||
child.transform.SetParent(this.transform);
|
||||
child.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
child.transform.localScale = Vector3.one;
|
||||
child.EnableScript("", "", type, this);
|
||||
|
||||
// Add Child
|
||||
Childs.Add(child);
|
||||
|
||||
// Load Child Script
|
||||
ConventionUtility.StartCoroutine(child.LoadScript(""));
|
||||
|
||||
LastLoadedScriptableObject = child;
|
||||
callback?.Invoke(child);
|
||||
|
||||
return child;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建子脚本
|
||||
/// 创建不需要脚本语句的子脚本对象
|
||||
/// </summary>
|
||||
/// <param name="type">指定类型</param>
|
||||
public IEnumerator NewSubScript([In] string type)
|
||||
public ScriptableObject NewSubScript([In] string type)
|
||||
{
|
||||
return DoGenerateSubScriptAsync(type, $"New {type}", null);
|
||||
return DoGenerateSubScript(type, $"New {type}", null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Demo.Game
|
||||
var childName = type;
|
||||
int childIndex = 1;
|
||||
var childFullNameWithoutExtension = childName;
|
||||
var extension = ".h";
|
||||
var extension = ".rscript";
|
||||
if (childDir.Exists())
|
||||
{
|
||||
childFullNameWithoutExtension = $"{childName}{(childIndex == 1 ? "" : childIndex.ToString())}";
|
||||
|
||||
Reference in New Issue
Block a user