void ValidateCreatedNewScript()
 {
     if (FSMScriptManager.ScriptExists(newScriptName))
     {
         isScriptCompiling = false;
         CreateState(newScriptName);
     }
 }
    public static void CreateFSMScript(string className, string path = "Assets/", string baseClass = "FSMState")
    {
        string classCode =
            @"
using UnityEngine;
using System.Collections;
public class " + className + " : " + baseClass + @"{
 
    public override void Enter(FSMState lastState)
    {
        base.Enter(lastState);
    }

    public override FSMEvent Process ()
	{
		return null;	
	}

    public override void Leave(FSMState nextState)
    {
        base.Leave(nextState);
    }

}";

        if (baseClass != "FSMState" && !FSMScriptManager.ScriptExists(baseClass))
        {
            FSMScriptManager.CreateFSMScript(baseClass, path);
        }

        string copyPath = path + className + ".cs";

        Debug.Log("Creating Classfile: " + copyPath);

        if (File.Exists(copyPath) == false)   // do not overwrite
        {
            using (StreamWriter outfile =
                       new StreamWriter(copyPath))
            {
                outfile.WriteLine(classCode);
            }//File written
        }
    }
 void ProcessCreateState()
 {
     if (selectedScriptCreationOptionIndex == 0)
     {
         if (!FSMScriptManager.ScriptExists(newScriptName))
         {
             FSMScriptManager.CreateFSMScript(newScriptName, MyFSMEditor.MyFSM.DefaultScriptPath, MyFSMEditor.MyFSM.BaseStateScriptClass);
             AssetDatabase.Refresh();
             isScriptCompiling = true;
         }
         else
         {
             Debug.LogError("Script " + stateName + " already exists!!!");
         }
     }
     else if (selectedScriptCreationOptionIndex == 1)
     {
         string existingScriptName = scriptList[selectedExistingScriptIndex];
         CreateState(existingScriptName);
     }
 }
 void Start()
 {
     scriptList = FSMScriptManager.GetAllFSMStateScripts().ToArray();
     Array.Sort <string>(scriptList);
 }