Example #1
0
 void OnEnable()
 {
     manager = (Runner.LocationManager)GameObject.FindObjectOfType(typeof(Runner.LocationManager));
     if (manager == null)
     {
         ErrorManager.Show("Error", "PlatformTypeEditor, manager == null");
         return;
     }
     if (manager.platformsInfo != null)
     {
         PlatformInfoManager.List.Clear();
         PlatformInfoManager.List.AddRange(manager.platformsInfo);
     }
     changed = true;
 }
Example #2
0
 public override void OnInspectorGUI()
 {
     Draw();
     GUI.color = ColorEditor.Title;
     if (GUILayout.Button("Add"))
     {
         PlatformInfoManager.List.Add(new Runner.PlatformInfo());
         manager.platformsInfo = PlatformInfoManager.List.ToArray();
     }
     GUI.color = Color.white;
     if (changed)
     {
         Runner.LocationManager manager = (Runner.LocationManager)GameObject.Find("Game").GetComponent(typeof(Runner.LocationManager));
         manager.platformsInfo = PlatformInfoManager.List.ToArray();
         changed = false;
     }
 }
Example #3
0
    void OnGUI()
    {
        target = GameObject.FindObjectOfType <Runner.LocationManager>();
        if (target == null)
        {
            GUI.color = Color.red;
            GUILayout.Label("ERROR, LocationManager not found!!!");
            GUI.color = Color.white;
            return;
        }

        sScrollView = EditorGUILayout.BeginScrollView(sScrollView);

        GUI.color = ColorEditor.Title;
        GUILayout.Label("Select prefabs to add to the list");
        GUI.color = Color.white;

        var selection = Selection.GetFiltered(typeof(Runner.PlatformObject), SelectionMode.Assets);

        sFoldoutSelected = EditorGUILayout.Foldout(sFoldoutSelected, "Selected Objects");
        if (sFoldoutSelected)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(30.0f);
            GUILayout.BeginVertical();

            GUI.color = ColorEditor.Title;
            var contains = false;
            foreach (var s in selection)
            {
                SelectedListPlaceholder(s);
                contains = true;
            }
            if (contains == false)
            {
                GUILayout.Label("no selected objects");
            }
            GUI.color = Color.white;
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }

        EditorGUILayout.Separator();

        GUI.color = ColorEditor.Title;
        GUILayout.Label("Lists");
        GUI.color = Color.white;

        sFoldoutPlatforms = EditorGUILayout.Foldout(sFoldoutPlatforms, "Platforms");
        if (sFoldoutPlatforms)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(30.0f);
            GUILayout.BeginVertical();

            GUI.color = ColorEditor.Title;
            var contains = false;
            foreach (var s in target.platforms)
            {
                SelectedListPlaceholder(s);
                contains = true;
            }
            if (contains == false)
            {
                GUILayout.Label("no platforms");
            }
            GUI.color = Color.white;
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }

        sFoldoutTransitionPlatforms = EditorGUILayout.Foldout(sFoldoutTransitionPlatforms, "Transition Platforms");
        if (sFoldoutTransitionPlatforms)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(30.0f);
            GUILayout.BeginVertical();

            GUI.color = ColorEditor.Title;
            var contains = false;
            foreach (var s in target.transitionPlatforms)
            {
                SelectedListPlaceholder(s);
                contains = true;
            }
            if (contains == false)
            {
                GUILayout.Label("no transition platforms");
            }
            GUI.color = Color.white;
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }

        sFoldoutStartPlatforms = EditorGUILayout.Foldout(sFoldoutStartPlatforms, "Start Platforms");
        if (sFoldoutStartPlatforms)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(30.0f);
            GUILayout.BeginVertical();

            GUI.color = ColorEditor.Title;
            var contains = false;
            foreach (var s in target.startPlatforms)
            {
                SelectedListPlaceholder(s);
                contains = true;
            }
            if (contains == false)
            {
                GUILayout.Label("no start platforms");
            }
            GUI.color = Color.white;
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }

        EditorGUILayout.Separator();
        EditorGUILayout.Separator();

        if (target.platforms.Any(s => s == null) || target.startPlatforms.Any(s => s == null) ||
            target.transitionPlatforms.Any(s => s == null))
        {
            GUI.color = ColorEditor.RgbToColor(255, 50, 50);
            GUILayout.Label("There are errors, correct please!", EditorStyles.boldLabel);
        }

        GUI.color = Color.cyan;
        if (GUILayout.Button("Auto Correct"))
        {
            var platforms = from p in target.platforms
                            where p != null && p.Mode == PlatformMode.Platform
                            select p;
            target.platforms = platforms.ToArray();

            var start = from s in target.startPlatforms
                        where s != null && s.Mode == PlatformMode.Platform
                        select s;
            target.startPlatforms = start.ToArray();

            var trans = from t in target.transitionPlatforms
                        where t != null && t.Mode == PlatformMode.Transition
                        select t;
            target.transitionPlatforms = trans.ToArray();
        }
        GUI.color = Color.white;

        EditorGUILayout.EndScrollView();
    }