예제 #1
0
        void  OnEnable()
        {
            if (!EditorPrefs.HasKey("ObjectPath"))
            {
                return;
            }
            var objectPath = EditorPrefs.GetString("ObjectPath");

            BuildingsCatalogueItems = AssetDatabase.LoadAssetAtPath(objectPath, typeof(BuildingsCatalogue)) as BuildingsCatalogue;
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }