public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        var mgr    = (GlobalManager)target;
        var levels = mgr.Levels;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Levels (" + levels.Length + ")", EditorStyles.boldLabel);

        var toRemove = -1;

        CustomGUIUtils.DrawSeparator();
        for (var i = 0; i < levels.Length; ++i)
        {
            var level = levels[i];
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(level.ToString());
            if (GUILayout.Button("X"))
            {
                toRemove = i;
            }
            EditorGUILayout.EndHorizontal();
        }
        CustomGUIUtils.DrawSeparator();

        if (toRemove >= 0)
        {
            ArrayUtility.RemoveAt(ref levels, toRemove);
            levels = levels.Where(lvl => SceneUtility.IsValidSceneName(lvl.SceneName)).ToArray();
        }

        var sceneName = SceneUtility.InspectSceneSelectionDropdown(null, null);

        if (SceneUtility.IsValidSceneName(sceneName))
        {
            ArrayUtility.Add(ref levels, new LevelInfo(sceneName));
        }

        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            mgr.Levels = levels;
            EditorUtility.SetDirty(target);
        }
    }
Example #2
0
    public override void OnInspectorGUI()
    {
        var spell = (Spell)target;

        serializedObject.Update();

        // start drawing spell
        spell.Cooldown = EditorGUILayout.FloatField("Cooldown", spell.Cooldown);


        CustomGUIUtils.DrawSeparator();
        InspectSpellTargetSettings(spell.Targets);

        CustomGUIUtils.DrawSeparator();
        InspectCastPhaseTemplate();

        CustomGUIUtils.DrawSeparator();
        InspectProjectilePhaseTemplate();

        CustomGUIUtils.DrawSeparator();
        InspectImpactPhaseTemplate();

        //if (GUI.changed) {
        // write values back
        serializedObject.ApplyModifiedProperties();
        EditorUtility.SetDirty(target);
        //}

        // TODO: For duplicate, we need to also duplicate all ScriptableObject sub assets
//		if (GUILayout.Button ("Duplicate")) {
//			var newSpell = Object.Instantiate(spell) as Spell;
//			ProjectWindowUtil.StartNameEditingIfProjectWindowExists(
//				newSpell.GetInstanceID(),
//				ScriptableObject.CreateInstance<EndNameEdit>(),
//				string.Format("{0}.asset", "new spell"),
//				AssetPreview.GetMiniThumbnail(newSpell),
//				null);
//		}
    }