void Awake() { instance = null; SetupSingleton(); SetupW8Path(); SetupContentReaders(); }
public override void OnInspectorGUI() { // Update w8Unity.EditorUpdate(); // Get properties var propWizardry8Path = Prop("Wizardry8Path"); // Browse for Wizardry8 path EditorGUILayout.Space(); GUILayoutHelper.Horizontal(() => { EditorGUILayout.LabelField(new GUIContent("Wizardry8 Path", "The local Wizardry8 path used for development only."), GUILayout.Width(EditorGUIUtility.labelWidth - 4)); EditorGUILayout.SelectableLabel(w8Unity.Wizardry8Path, EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); if (GUILayout.Button("Browse...")) { string path = EditorUtility.OpenFolderPanel("Locate Wizardry8 Path", "", ""); if (!string.IsNullOrEmpty(path)) { if (!Wizardry8Unity.ValidateW8Path(path)) { EditorUtility.DisplayDialog("Invalid Path", "The selected Wizardry8 path is invalid", "Close"); } else { w8Unity.Wizardry8Path = path; propWizardry8Path.stringValue = path; w8Unity.EditorResetW8Path(); } } } if (GUILayout.Button("Clear")) { w8Unity.EditorClearW8Path(); EditorUtility.SetDirty(target); } }); // Prompt user to set Wizardry8 path if (string.IsNullOrEmpty(w8Unity.Wizardry8Path)) { EditorGUILayout.HelpBox("Please set the Wizardry8 path of your Wizardry installation.", MessageType.Info); return; } // Display other GUI items //DisplayOptionsGUI(); DisplayImporterGUI(); // Save modified properties serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
public static bool FindWizardry8Unity(out Wizardry8Unity dfUnityOut) { dfUnityOut = GameObject.FindObjectOfType(typeof(Wizardry8Unity)) as Wizardry8Unity; if (dfUnityOut == null) { LogMessage("Could not locate Wizardry8Unity GameObject instance in scene!", true); return(false); } return(true); }
private void SetupSingleton() { if (instance == null) { instance = this; } else if (instance != this) { if (Application.isPlaying) { LogMessage("Multiple Wizardry8Unity instances detected in scene!", true); Destroy(gameObject); } } }
private void SetupContentReaders(bool force = false) { if (reader == null || force) { // Ensure content readers available even when path not valid if (isPathValidated) { Wizardry8Unity.LogMessage(string.Format("Setting up content readers with W8 path '{0}'.", Wizardry8Path)); reader = new ContentReader(Wizardry8Path); } else { Wizardry8Unity.LogMessage(string.Format("Setting up content readers without W8 path. Not all features will be available.")); reader = new ContentReader(string.Empty); } } }