public static Component AddHandlerScript(ComponentAdapter adapter, AddEventHandlerPersistedData data) { //Debug.Log(string.Format(@"AddHandlerScript [adapter: {0}, data: {1}]", adapter, data)); var component = adapter.gameObject.GetComponent(data.ClassName); Component addedComponent = null; /** * 1. Check if the component is already attached * */ if (null != component) { string text = string.Format(@"Script ""{0}"" is already attached to the selected game object.", data.ClassName); Debug.LogWarning(text); EditorUtility.DisplayDialog("Duplicated script", text, "OK"); } else { /** * 2. Add component * */ addedComponent = adapter.gameObject.AddComponent(data.ClassName); } return(addedComponent); }
public static void Run(ComponentAdapter adapter, AddEventHandlerPersistedData persistedData) { //if (EditorApplication.isPlaying) //{ // //Debug.Log("Stopping..."); // EditorApplication.isPlaying = false; //} _adapter = adapter; //Debug.Log("*** persistedData.ScriptPath: " + persistedData.ScriptPath); //Debug.Log("*** persistedData.Snippet: " + persistedData.Snippet); /** * 4. Save file * */ SaveFile(persistedData.ScriptPath, persistedData.Snippet); }