public void ResetToDefaults() { if (_tiedBehavior != null) { _tiedBehavior.ResetToDefaults(); } ButtonName = _defaultName; Setup(); }
/// <summary> /// Setup all the variables to be used within the editor /// </summary> public void Initialize() { titleContent = new GUIContent("Forge Wizard"); ProVersion = EditorGUIUtility.isProSkin; ForgeClassObject.IDENTITIES = 0; _referenceBitWise = new List <string>(); _referenceBitWise.Add("0x1"); _referenceBitWise.Add("0x2"); _referenceBitWise.Add("0x4"); _referenceBitWise.Add("0x8"); _referenceBitWise.Add("0x10"); _referenceBitWise.Add("0x20"); _referenceBitWise.Add("0x40"); _referenceBitWise.Add("0x80"); _referenceVariables = new Dictionary <object, string>(); _referenceVariables.Add(typeof(bool).Name, "bool"); _referenceVariables.Add(typeof(byte).Name, "byte"); _referenceVariables.Add(typeof(char).Name, "char"); _referenceVariables.Add(typeof(short).Name, "short"); _referenceVariables.Add(typeof(ushort).Name, "ushort"); _referenceVariables.Add(typeof(int).Name, "int"); _referenceVariables.Add(typeof(uint).Name, "uint"); _referenceVariables.Add(typeof(float).Name, "float"); _referenceVariables.Add(typeof(long).Name, "long"); _referenceVariables.Add(typeof(ulong).Name, "ulong"); _referenceVariables.Add(typeof(double).Name, "double"); _referenceVariables.Add(typeof(string).Name, "string"); _referenceVariables.Add(typeof(Vector2).Name, "Vector2"); _referenceVariables.Add(typeof(Vector3).Name, "Vector3"); _referenceVariables.Add(typeof(Vector4).Name, "Vector4"); _referenceVariables.Add(typeof(Quaternion).Name, "Quaternion"); _referenceVariables.Add(typeof(Color).Name, "Color"); _referenceVariables.Add(typeof(object).Name, "object"); _referenceVariables.Add(typeof(object[]).Name, "object[]"); _referenceVariables.Add(typeof(byte[]).Name, "byte[]"); _scrollView = Vector2.zero; _editorButtons = new List <ForgeEditorButton>(); _instance = this; _storingPath = Path.Combine(Application.dataPath, GENERATED_FOLDER_PATH); _userStoringPath = Path.Combine(Application.dataPath, USER_GENERATED_FOLDER_PATH); if (!Directory.Exists(_storingPath)) { Directory.CreateDirectory(_storingPath); } if (!Directory.Exists(_userStoringPath)) { Directory.CreateDirectory(_userStoringPath); } string[] files = Directory.GetFiles(_storingPath, "*.cs", SearchOption.TopDirectoryOnly); string[] userFiles = Directory.GetFiles(_userStoringPath, "*.cs", SearchOption.TopDirectoryOnly); //if (File.Exists(Path.Combine(Application.persistentDataPath, FN_WIZARD_DATA))) //Check for our temp file, this will make it so that we can load this data from memory regaurdless of errors //{ // IFormatter bFormatter = new BinaryFormatter(); // bool updateColors = false; // using (Stream s = new FileStream(Path.Combine(Application.persistentDataPath, FN_WIZARD_DATA), FileMode.Open, FileAccess.Read, FileShare.Read)) // { // try // { // object deserializedObject = bFormatter.Deserialize(s); // if (deserializedObject != null) // { // _editorButtons = (List<ForgeEditorButton>)deserializedObject; // bool cleared = true; // for (int i = 0; i < _editorButtons.Count; ++i) // { // _editorButtons[i].SetupLists(); // if (_editorButtons[i].TiedObject == null) // { // cleared = false; // break; // } // } // if (cleared) // updateColors = true; // else // { // _editorButtons = new List<ForgeEditorButton>(); // ReloadScripts(files, userFiles); // } // } // else // ReloadScripts(files, userFiles); // } // catch // { // ReloadScripts(files, userFiles); // } // } // if (updateColors) // { // for (int i = 0; i < _editorButtons.Count; ++i) // { // _editorButtons[i].UpdateButtonColor(); // if (_editorButtons[i].IsNetworkObject) // ForgeClassObject.IDENTITIES++; // } // } //} //else ReloadScripts(files, userFiles); #region Texture Loading Arrow = Resources.Load <Texture2D>("Arrow"); SideArrow = Resources.Load <Texture2D>("SideArrow"); SideArrowInverse = FlipTexture(SideArrow); Star = Resources.Load <Texture2D>("Star"); TrashIcon = Resources.Load <Texture2D>("Trash"); SubtractIcon = Resources.Load <Texture2D>("Subtract"); AddIcon = Resources.Load <Texture2D>("Add"); SaveIcon = Resources.Load <Texture2D>("Save"); LightbulbIcon = Resources.Load <Texture2D>("Lightbulb"); BackgroundTexture = new Texture2D(1, 1); BackgroundTexture.SetPixel(0, 0, LightsOffBackgroundColor); BackgroundTexture.Apply(); #endregion _createUndo = () => { if (ActiveButton.IsDirty) { if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will trash the current object", "Yes", "No")) { ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } } else { //We don't care because they didn't do anything ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } }; _modifyUndo = () => { bool isDirty = ActiveButton.IsDirty; if (isDirty) { if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will undo the current changes", "Yes", "No")) { ActiveButton.ResetToDefaults(); ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } } else { ActiveButton.ResetToDefaults(); ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } }; AssetDatabase.Refresh(); }
/// <summary> /// Setup all the variables to be used within the editor /// </summary> public void Initialize() { titleContent = new GUIContent("Forge Wizard"); ProVersion = EditorGUIUtility.isProSkin; ForgeClassObject.IDENTITIES = 0; _referenceBitWise = new List <string>(); _referenceBitWise.Add("0x1"); _referenceBitWise.Add("0x2"); _referenceBitWise.Add("0x4"); _referenceBitWise.Add("0x8"); _referenceBitWise.Add("0x10"); _referenceBitWise.Add("0x20"); _referenceBitWise.Add("0x40"); _referenceBitWise.Add("0x80"); _referenceVariables = new Dictionary <object, string>(); _referenceVariables.Add(typeof(bool).Name, "bool"); _referenceVariables.Add(typeof(byte).Name, "byte"); _referenceVariables.Add(typeof(char).Name, "char"); _referenceVariables.Add(typeof(short).Name, "short"); _referenceVariables.Add(typeof(ushort).Name, "ushort"); _referenceVariables.Add(typeof(int).Name, "int"); _referenceVariables.Add(typeof(uint).Name, "uint"); _referenceVariables.Add(typeof(float).Name, "float"); _referenceVariables.Add(typeof(long).Name, "long"); _referenceVariables.Add(typeof(ulong).Name, "ulong"); _referenceVariables.Add(typeof(double).Name, "double"); _referenceVariables.Add(typeof(string).Name, "string"); _referenceVariables.Add(typeof(Vector2).Name, "Vector2"); _referenceVariables.Add(typeof(Vector3).Name, "Vector3"); _referenceVariables.Add(typeof(Vector4).Name, "Vector4"); _referenceVariables.Add(typeof(Quaternion).Name, "Quaternion"); _referenceVariables.Add(typeof(Color).Name, "Color"); _referenceVariables.Add(typeof(object).Name, "object"); _referenceVariables.Add(typeof(object[]).Name, "object[]"); _referenceVariables.Add(typeof(byte[]).Name, "byte[]"); _scrollView = Vector2.zero; _editorButtons = new List <ForgeEditorButton>(); _instance = this; _storingPath = Path.Combine(Application.dataPath, GENERATED_FOLDER_PATH); _userStoringPath = Path.Combine(Application.dataPath, USER_GENERATED_FOLDER_PATH); if (!Directory.Exists(_storingPath)) { Directory.CreateDirectory(_storingPath); } if (!Directory.Exists(_userStoringPath)) { Directory.CreateDirectory(_userStoringPath); } string[] files = Directory.GetFiles(_storingPath, "*", SearchOption.TopDirectoryOnly); string[] userFiles = Directory.GetFiles(_userStoringPath, "*", SearchOption.TopDirectoryOnly); List <ForgeClassObject> correctFiles = new List <ForgeClassObject>(); for (int i = 0; i < files.Length; ++i) { if (!files[i].EndsWith(".meta")) //Ignore all meta files { correctFiles.Add(new ForgeClassObject(files[i])); } } for (int i = 0; i < userFiles.Length; ++i) { if (!userFiles[i].EndsWith(".meta")) //Ignore all meta files { correctFiles.Add(new ForgeClassObject(userFiles[i])); } } if (!ForgeClassObject.HasExactFilename(correctFiles, "NetworkObjectFactory")) { MakeForgeFactory(); //We do not have the Forge Factory, we need to make this! } for (int i = 0; i < correctFiles.Count; ++i) { var btn = new ForgeEditorButton(correctFiles[i]); if (btn.IsNetworkObject || btn.IsNetworkBehavior) { _editorButtons.Add(btn); } } #region Texture Loading Arrow = Resources.Load <Texture2D>("Arrow"); SideArrow = Resources.Load <Texture2D>("SideArrow"); SideArrowInverse = FlipTexture(SideArrow); Star = Resources.Load <Texture2D>("Star"); TrashIcon = Resources.Load <Texture2D>("Trash"); SubtractIcon = Resources.Load <Texture2D>("Subtract"); AddIcon = Resources.Load <Texture2D>("Add"); SaveIcon = Resources.Load <Texture2D>("Save"); LightbulbIcon = Resources.Load <Texture2D>("Lightbulb"); BackgroundTexture = new Texture2D(1, 1); BackgroundTexture.SetPixel(0, 0, LightsOffBackgroundColor); BackgroundTexture.Apply(); #endregion _createUndo = () => { if (ActiveButton.IsDirty) { if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will trash the current object", "Yes", "No")) { ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } } else { //We don't care because they didn't do anything ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } }; _modifyUndo = () => { bool isDirty = ActiveButton.IsDirty; if (isDirty) { if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will undo the current changes", "Yes", "No")) { ActiveButton.ResetToDefaults(); ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } } else { ActiveButton.ResetToDefaults(); ActiveButton = null; ChangeMenu(ForgeEditorActiveMenu.Main); } }; AssetDatabase.Refresh(); }