static void LoadSettings() { settingsPath = PlayerPrefs.GetString(SETTINGS_PATH_KEY, ""); settings = null; //Find path. Try to load settings if (!string.IsNullOrEmpty(settingsPath)) { settings = AssetDatabase.LoadAssetAtPath <BuildManagerSettings>(settingsPath); if (settings == null) { settingsPath = null; } } //No path, or cant locate asset at path. Try to find settings in assets. if (string.IsNullOrEmpty(settingsPath)) { string[] guids = AssetDatabase.FindAssets("t:BuildManagerSettings"); if (guids.Length >= 2) { Debug.LogError("[BuildManagerWindow]. 2+ BuildManagerSettings exist. Consider on using only 1 setting. The first on will be used."); } if (guids.Length != 0) { settingsPath = AssetDatabase.GUIDToAssetPath(guids[0]); PlayerPrefs.SetString(SETTINGS_PATH_KEY, settingsPath); settings = AssetDatabase.LoadAssetAtPath <BuildManagerSettings>(settingsPath); } } //Cant find settings. Create new if (settings == null) { settings = (BuildManagerSettings)ScriptableObject.CreateInstance(typeof(BuildManagerSettings)); AssetDatabase.CreateAsset(settings, SETTINGS_DEFAULT_PATH); settingsPath = SETTINGS_DEFAULT_PATH; PlayerPrefs.SetString(SETTINGS_PATH_KEY, SETTINGS_DEFAULT_PATH); } sequencesList = new InspectorList <BuildSequence>(); sequencesList.Init(settings.sequences, "Builds sequences", (BuildSequence seq, int i) => seq.editorName); buidsList = new InspectorList <BuildData>(); buidsList.Init(sequencesList.Selected.builds, "Builds", FormBuildNameInList); sequencesList.OnChangeSelectionAction += OnSequenceSelectionChanged; buidsList.OnChangeSelectionAction += OnBuildSelectionChanged; }
static void OnSequenceSelectionChanged(BuildSequence sequence) { buidsList.Init(sequence.builds, "Builds", FormBuildNameInList); }