private static void CreateScript(string name, AssetCreator.AssetClassType classType, bool cSharp) { string text = AssetDatabase.GetAssetPath(Selection.activeObject); if (text == string.Empty) { text = "Assets"; } else if (Path.GetExtension(text) != string.Empty) { text = text.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), string.Empty); } string path = AssetDatabase.GenerateUniqueAssetPath(text + "/" + name + ((!cSharp) ? ".js" : ".cs")); StreamWriter streamWriter = new StreamWriter(path, false); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); string value = string.Empty; switch (classType) { case AssetCreator.AssetClassType.Action: value = AssetCreator.ActionTaskContents(fileNameWithoutExtension, cSharp); break; case AssetCreator.AssetClassType.Conditional: value = AssetCreator.ConditionalTaskContents(fileNameWithoutExtension, cSharp); break; case AssetCreator.AssetClassType.SharedVariable: value = AssetCreator.SharedVariableContents(fileNameWithoutExtension); break; } streamWriter.Write(value); streamWriter.Close(); AssetDatabase.Refresh(); }
public static void CreateExternalBehaviorTree() { Type type = Type.GetType("BehaviorDesigner.Runtime.ExternalBehaviorTree, Assembly-CSharp"); if (type == null) { type = Type.GetType("BehaviorDesigner.Runtime.ExternalBehaviorTree, Assembly-CSharp-firstpass"); } AssetCreator.CreateAsset(type, "NewExternalBehavior"); }
public static void ShowWindow(AssetCreator.AssetClassType classType, bool cSharp) { AssetCreator window = EditorWindow.GetWindow <AssetCreator>(true, "Asset Name"); EditorWindow arg_25_0 = window; Vector2 vector = new Vector2(300f, 55f); window.maxSize = vector; arg_25_0.minSize = vector; window.ClassType = classType; window.CSharp = cSharp; }
private void OnGUI() { this.m_AssetName = EditorGUILayout.TextField("Name", this.m_AssetName, new GUILayoutOption[0]); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); if (GUILayout.Button("OK", new GUILayoutOption[0])) { AssetCreator.CreateScript(this.m_AssetName, this.m_classType, this.m_CSharp); base.Close(); } if (GUILayout.Button("Cancel", new GUILayoutOption[0])) { base.Close(); } EditorGUILayout.EndHorizontal(); }
public static void CreateCSharpActionTask() { AssetCreator.ShowWindow(AssetCreator.AssetClassType.Action, true); }
public static void CreateSharedVariable() { AssetCreator.ShowWindow(AssetCreator.AssetClassType.SharedVariable, true); }
public static void CreateUnityscriptConditionalTask() { AssetCreator.ShowWindow(AssetCreator.AssetClassType.Conditional, false); }
public static void CreateUnityscriptActionTask() { AssetCreator.ShowWindow(AssetCreator.AssetClassType.Action, false); }
public static void CreateCSharpConditionalTask() { AssetCreator.ShowWindow(AssetCreator.AssetClassType.Conditional, true); }