예제 #1
0
        public override void OnInspectorGUI()
        {
            m_editorUtils.Initialize(); // Do not remove this!
            m_spawnerSettings = (SpawnerSettings)target;

            string message = m_editorUtils.GetTextValue("Intro");;

            EditorGUILayout.HelpBox(message, MessageType.Info, true);

            if (GUILayout.Button(m_editorUtils.GetContent("AddToScene")))
            {
                m_spawnerSettings.CreateSpawner();
            }

            GUILayout.Label(m_editorUtils.GetContent("SpawnRulePreview"), m_editorUtils.Styles.heading);

            GaiaResource resource = m_spawnerSettings.m_resources;// (GaiaResource)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_spawnerSettings.m_resourcesGUID), typeof(GaiaResource));

            foreach (SpawnRule rule in m_spawnerSettings.m_spawnerRules)
            {
                m_editorUtils.LabelField("Name", new GUIContent(rule.m_name));
                m_editorUtils.LabelField("Type", new GUIContent(rule.m_resourceType.ToString()));


                Texture2D resourceTexture = SpawnerEditor.GetSpawnRulePreviewTexture(rule, resource);

                if (resourceTexture != null)
                {
                    m_editorUtils.Image(resourceTexture, 100, 100);
                }
            }
        }
예제 #2
0
        public void RefreshSpawnerListEntries()
        {
#if UNITY_EDITOR
            //walk through the references spawner settings files, and if they have a "last saved path" reload them again in this preset to make sure the reference in there is correct.
            foreach (BiomeSpawnerListEntry bsle in m_spawnerPresetList)
            {
                if (bsle.m_spawnerSettings != null)
                {
                    if (!string.IsNullOrEmpty(bsle.m_spawnerSettings.m_lastGUIDSaved))
                    {
                        SpawnerSettings spawnerSettings = (SpawnerSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(bsle.m_spawnerSettings.m_lastGUIDSaved), typeof(SpawnerSettings));
                        if (spawnerSettings != null)
                        {
                            bsle.m_spawnerSettings = spawnerSettings;
                        }
                    }
                }
            }
#endif
        }