예제 #1
0
 private void OnEnable()
 {
     m_biomePreset = (BiomePreset)target;
     //Init editor utils
     if (m_editorUtils == null)
     {
         // Get editor utils for this
         m_editorUtils = PWApp.GetEditorUtils(this);
     }
     m_biomePreset.RefreshSpawnerListEntries();
     CreateSpawnerPresetList();
 }
예제 #2
0
        public override void OnInspectorGUI()
        {
            m_editorUtils.Initialize(); // Do not remove this!
            m_biomePreset = (BiomePreset)target;
            serializedObject.Update();

            m_editorUtils.Panel("BiomeSettings", DrawBiomeSettings, true);

            if (GUILayout.Button(m_editorUtils.GetContent("AddToScene")))
            {
                BiomeController newBiome = m_biomePreset.CreateBiome(true);
                Selection.activeGameObject = newBiome.gameObject;
            }
        }
예제 #3
0
        public void LoadFromPreset(BiomePreset presetToLoad)
        {
            try
            {
                presetToLoad.RefreshSpawnerListEntries();
                m_autoSpawners.Clear();
                //Remove all child spawners
                for (int i = transform.childCount - 1; i >= 0; i--)
                {
                    DestroyImmediate(transform.GetChild(i).gameObject);
                }

                //Track created spawners
                List <Spawner> createdSpawners = new List <Spawner>();
                int            totalCount      = presetToLoad.m_spawnerPresetList.Count();
                int            currentCount    = 0;
                foreach (BiomeSpawnerListEntry spawnerListEntry in presetToLoad.m_spawnerPresetList)
                {
                    createdSpawners.Add(spawnerListEntry.m_spawnerSettings.CreateSpawner(false, transform));
                    //GaiaUtils.DisplayProgressBarNoEditor("Creating Tools", "Creating Biome " + this.name, ++currentStep / totalSteps);
                    if (ProgressBar.Show(ProgressBarPriority.CreateBiomeTools, "Loading Biome Preset", "Creating Tools", ++currentCount, totalCount, false, true))
                    {
                        break;
                    }
                }
                if (createdSpawners.Count > 0)
                {
                    m_settings.m_range = createdSpawners[0].m_settings.m_spawnRange;
                }

                foreach (Spawner spawner in createdSpawners)
                {
                    m_autoSpawners.Add(new AutoSpawner()
                    {
                        isActive = true, status = AutoSpawnerStatus.Initial, spawner = spawner
                    });
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("Error while loading biome preset settings, Message: " + ex.Message + ", Stack Trace: " + ex.StackTrace);
            }
            finally
            {
                ProgressBar.Clear(ProgressBarPriority.CreateBiomeTools);
            }
        }