void OnEnable() { if (!EditorPrefs.HasKey("ObjectPath")) { return; } var objectPath = EditorPrefs.GetString("ObjectPath"); BuildingsCatalogueItems = AssetDatabase.LoadAssetAtPath(objectPath, typeof(BuildingsCatalogue)) as BuildingsCatalogue; }
private void CreateNewItemList() { // There is no overwrite protection here! // There is No "Are you sure you want to overwrite your existing object?" if it exists. // This should probably get a string from the user to create a new name and pass it ... _viewIndex = 1; BuildingsCatalogueItems = CreateCatalogueStorage.Create(); if (!BuildingsCatalogueItems) { return; } BuildingsCatalogueItems.Buildings = new List <BuildingData>(); var relPath = AssetDatabase.GetAssetPath(BuildingsCatalogueItems); EditorPrefs.SetString("ObjectPath", relPath); }
private void OpenItemList() { var absPath = EditorUtility.OpenFilePanel("Select Buildings List", "", ""); if (!absPath.StartsWith(Application.dataPath)) { return; } var relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length); BuildingsCatalogueItems = AssetDatabase.LoadAssetAtPath(relPath, typeof(BuildingsCatalogue)) as BuildingsCatalogue; if (BuildingsCatalogueItems != null && BuildingsCatalogueItems.Buildings == null) { BuildingsCatalogueItems.Buildings = new List <BuildingData>(); } if (BuildingsCatalogueItems) { EditorPrefs.SetString("ObjectPath", relPath); } }