private static void CreateScript(string name, 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 AssetClassType.Action: value = ActionTaskContents(fileNameWithoutExtension, cSharp); break; case AssetClassType.Conditional: value = ConditionalTaskContents(fileNameWithoutExtension, cSharp); break; case AssetClassType.SharedVariable: value = SharedVariableContents(fileNameWithoutExtension); break; } streamWriter.Write(value); streamWriter.Close(); AssetDatabase.Refresh(); }
public static void ShowWindow(AssetClassType classType, bool cSharp) { AssetCreator window = 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; }