Ejemplo n.º 1
0
    protected bool HandleMissingData()
    {
        if (Manager == null)
        {
            Manager = InstanceFinder.DataManager;
            if (Manager == null)
            {
                ErrorDrawer.MissingAudioManager();
            }
        }

        if (Manager != null)
        {
            bool areAnyMissing = ErrorDrawer.IsDataMissing(Manager);

            if (areAnyMissing)
            {
                Manager.Load();
            }
            if (ErrorDrawer.IsDataMissing(Manager))
            {
                ErrorDrawer.MissingData(Manager);
                return(false);
            }
            else
            {
                return(true);
            }
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 2
0
    void OnGUI()
    {
        KeyboardWindowControls();
        if (Manager == null)
        {
            Manager = InstanceFinder.DataManager;
            if (Manager == null)
            {
                ErrorDrawer.MissingAudioManager();
            }
        }
        if (Manager != null)
        {
            bool missingaudio      = Manager.AudioTree == null;
            bool missingaudioEvent = Manager.EventTree == null;
            bool missingbus        = Manager.BusTree == null;
            bool missingBank       = Manager.BankLinkTree == null;

            bool areAnyMissing = missingaudio || missingaudioEvent || missingbus || missingBank;

            if (areAnyMissing)
            {
                DrawMissingDataCreation();
                return;
            }
        }
        else
        {
            return;
        }

        isDirty = false;

        EditorGUILayout.BeginVertical();
        EditorGUILayout.EndVertical();
        selectedToolbar = GUILayout.Toolbar(selectedToolbar, toolbarOptions);

        if (selectedToolbar == 0)
        {
            isDirty |= busGUI.OnGUI(LeftWidth, (int)position.height - topHeight);
        }

        if (selectedToolbar == 1)
        {
            isDirty |= bankGUI.OnGUI(LeftWidth, (int)position.height);
        }

        if (selectedToolbar == 2)
        {
            DrawMissingDataCreation();

            DrawStartFromScratch();
        }

        if (isDirty)
        {
            Repaint();
        }

        PostOnGUI();
    }
Ejemplo n.º 3
0
    public override void OnInspectorGUI()
    {
        if (!InAudioInstanceFinder.IsValid)
        {
            EditorGUILayout.HelpBox("Please add the InAudio Manager to the scene", MessageType.Info);
            if (GUILayout.Button("Add manager to scene"))
            {
                ErrorDrawer.AddManagerToScene();
            }
        }

        serializedObject.Update();
        EditorGUI.BeginChangeCheck();
        EditorGUILayout.PropertyField(serializedObject.FindProperty("SplineAudioEvent"));
        EditorGUILayout.Separator();

        bool add       = GUILayout.Button("Add Node");
        bool selectNew = false;

        if (GUILayout.Button("Add and Select"))
        {
            add       = true;
            selectNew = true;
        }

        var nodeArray     = serializedObject.FindProperty("Nodes");
        var nodeArraySize = nodeArray.FindPropertyRelative("Array.size");

        var connectionArray     = serializedObject.FindProperty("Connections");
        var connectionArraySize = connectionArray.FindPropertyRelative("Array.size");

        nodeArray.isExpanded = EditorGUILayout.Foldout(nodeArray.isExpanded, "Nodes");
        DrawList(nodeArray, nodeArraySize, i =>
        {
            var node = nodeArray.GetArrayElementAtIndex(i).objectReferenceValue as InSplineNode;

            nodeArray.DeleteArrayElementAtIndex(i);
            nodeArray.DeleteArrayElementAtIndex(i);

            for (int j = 0; j < connectionArray.arraySize; j++)
            {
                var prop = connectionArray.GetArrayElementAtIndex(j);
                if (prop.FindPropertyRelative("NodeA").objectReferenceValue == node ||
                    prop.FindPropertyRelative("NodeB").objectReferenceValue == node)
                {
                    connectionArray.DeleteArrayElementAtIndex(j);
                    --j;
                }
            }

            if (node != null)
            {
                UndoHelper.Destroy(node.gameObject);
            }
        });

        connectionArray.isExpanded = EditorGUILayout.Foldout(connectionArray.isExpanded, "Connections");
        DrawList(connectionArray, connectionArraySize, connectionArray.DeleteArrayElementAtIndex);

        if (add)
        {
            UndoHelper.DoInGroup(() =>
            {
                    #if UNITY_4_1 || UNITY_4_2
                Undo.RegisterSceneUndo("Delete element in spline");
                    #else
                UndoAll("Add new spline node");
                    #endif

                GameObject newNodeGO         = UndoHelper.CreateGO(SplineController.gameObject.name + " Node");
                var newNode                  = newNodeGO.AddComponent <InSplineNode>();
                newNodeGO.transform.position = SplineController.transform.position;
                newNode.SplineController     = SplineController;

                newNodeGO.transform.parent = SplineController.transform;

                newNodeGO.transform.position = SplineController.transform.position +
                                               SplineController.transform.forward;

                int count = SplineController.Nodes.Count;
                if (count > 0)
                {
                    SplineController.Nodes[0].ConnectTo(newNode);
                }

                SplineController.Nodes.Add(newNode);

                if (selectNew)
                {
                    Selection.activeGameObject = newNodeGO;
                }
            });
        }

        if (EditorGUI.EndChangeCheck())
        {
            serializedObject.ApplyModifiedProperties();
        }
    }