Esempio n. 1
0
        private void DrawMissingDataCreation()
        {
            if (ErrorDrawer.IsDataMissing(Manager))
            {
                EditorGUILayout.BeginVertical();

                if (!ErrorDrawer.IsAllDataMissing(Manager))
                {
                    EditorGUILayout.HelpBox("Some or all project data is missing. This may be because of new project data is required in this version of InAudio",
                                            MessageType.Warning, true);
                    if (GUILayout.Button("Create missing content", GUILayout.Height(30)))
                    {
                        MissingDataHelper.CreateIfMissing(Manager);

                        Manager.ForceLoad();
#if !UNITY_5_2
                        EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene());
                        EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
#else
                        EditorApplication.MarkSceneDirty();
                        EditorApplication.SaveCurrentSceneIfUserWantsTo();
#endif
                    }
                }

                DrawStartFromScratch();

                EditorGUILayout.EndVertical();
            }
        }
Esempio n. 2
0
 private void DrawStartFromScratch()
 {
     Repeater.Repeat(8, () =>
     {
         EditorGUILayout.Separator();
     });
     EditorGUILayout.HelpBox("Warning, this button will delete the entire InAudio project and create a new. This process cannot be undone.", MessageType.Error);
     if (GUILayout.Button("Start over from scratch", GUILayout.Height(30)))
     {
         if (ErrorDrawer.IsAllDataMissing(Manager) ||
             EditorUtility.DisplayDialog("Create new project?", "This will delete ALL data!",
                                         "Start over from scratch", "Do nothing"))
         {
             MissingDataHelper.StartFromScratch(Manager);
         }
     }
 }
Esempio n. 3
0
      protected bool HandleMissingData()
      {
          if (InAudioInstanceFinder.InAudioGuiUserPrefs == null)
          {
              ErrorDrawer.MissingGuiUserPrefs();
              return(false);
          }

          if (Manager == null)
          {
              Manager = InAudioInstanceFinder.DataManager;
              if (Manager == null)
              {
                  ErrorDrawer.MissingAudioManager();
              }
          }

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

              if (areAnyMissing)
              {
                  Manager.Load();
              }
              if (ErrorDrawer.IsAllDataMissing(Manager))
              {
                  ErrorDrawer.AllDataMissing(Manager);
                  return(false);
              }
              if (ErrorDrawer.IsDataMissing(Manager))
              {
                  ErrorDrawer.MissingData(Manager);
                  return(false);
              }
              else
              {
                  return(true);
              }
          }
          else
          {
              return(false);
          }
      }
Esempio n. 4
0
        private void OnGUI()
        {
            bankGUI.BaseOnGUI();
            CheckForClose();
            if (Manager == null)
            {
                Manager = InAudioInstanceFinder.DataManager;
                if (Manager == null)
                {
                    ErrorDrawer.MissingAudioManager();
                }
            }
            if (Manager != null)
            {
                bool missingaudio      = Manager.AudioTree == null;
                bool missingaudioEvent = Manager.EventTree == null;
                bool missingBank       = Manager.BankLinkTree == null;
                bool missingMusic      = Manager.MusicTree == null;

                bool areAllMissing = missingaudio && missingaudioEvent && missingBank && missingMusic;
                bool areAnyMissing = missingaudio || missingaudioEvent || missingBank || missingMusic;

                if (areAllMissing)
                {
                    ErrorDrawer.AllDataMissing(Manager);
                    return;
                }
                else if (areAnyMissing)
                {
                    DrawMissingDataCreation();
                    return;
                }
            }
            else
            {
                return;
            }

            isDirty = false;

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

            if (selectedToolbar == 0)
            {
                isDirty |= bankGUI.OnGUI(LeftWidth, (int)position.height - (int)EditorGUIUtility.singleLineHeight);
            }

            if (selectedToolbar == 1)
            {
                isDirty |= integrityGUI.OnGUI();
            }

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

                DrawStartFromScratch();
            }

            if (isDirty)
            {
                Repaint();
            }

            PostOnGUI();
        }
Esempio n. 5
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)
                {
                    InUndoHelper.Destroy(node.gameObject);
                }
            });

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

            if (add)
            {
                InUndoHelper.DoInGroup(() =>
                {
                    UndoAll("Add new spline node");

                    GameObject newNodeGO         = InUndoHelper.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();
            }
        }
Esempio n. 6
0
        private void OnGUI()
        {
            CheckForClose();
            if (Manager == null)
            {
                Manager = InAudioInstanceFinder.DataManager;
                if (Manager == null)
                {
                    ErrorDrawer.MissingAudioManager();
                }
            }
            if (Manager != null)
            {
                bool areAllMissing = ErrorDrawer.IsAllDataMissing(Manager);
                bool areAnyMissing = ErrorDrawer.IsDataMissing(Manager);

                if (areAllMissing)
                {
                    ErrorDrawer.AllDataMissing(Manager);
                    return;
                }
                else if (areAnyMissing)
                {
                    DrawMissingDataCreation();
                    return;
                }
            }
            else
            {
                return;
            }

            isDirty = false;

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


            if (selectedToolbar == 0)
            {
                isDirty |= integrityGUI.OnGUI();
            }

            if (selectedToolbar == 1)
            {
                bool areAnyMissing = ErrorDrawer.IsDataMissing(Manager);
                if (!areAnyMissing)
                {
                    EditorGUILayout.HelpBox("Everything seems good, all InAudio projects part are accounted for.", MessageType.Info);
                }


                DrawMissingDataCreation();

                DrawStartFromScratch();
            }

            if (isDirty)
            {
                Repaint();
            }

            PostOnGUI();
        }
        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();
            if (serializedObject.FindProperty("SplineController").hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Different spline controllers", MessageType.Warning);
                return;
            }
            if (SplineNode.SplineController == null)
            {
                EditorGUILayout.HelpBox("Missing spline controller, please assign one", MessageType.Warning);
            }

            if (InAudioInstanceFinder.IsValid)
            {
                InAudioInstanceFinder.InAudioGuiUserPrefs.SelectedSplineController = SplineNode.SplineController;
            }

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

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


            var objectField = EditorGUILayout.ObjectField("Controlling Spline", serializedObject.FindProperty("SplineController").objectReferenceValue, typeof(InSpline), true);

            if (serializedObject.FindProperty("SplineController").objectReferenceValue == null)
            {
                serializedObject.FindProperty("SplineController").objectReferenceValue = objectField;
            }

            if (Selection.objects.Length == 1)
            {
                GUILayout.Button("Drag node here to connect");
                OnDragging.DraggingObject <Object>(GUILayoutUtility.GetLastRect(), o =>
                {
                    GameObject go = o as GameObject;
                    if (go != null)
                    {
                        var node = go.GetComponent <InSplineNode>();
                        if (node != SplineNode && !SplineNode.SplineController.ContainsConnection(SplineNode, node))
                        {
                            return(true);
                        }
                    }
                    return(false);
                }, o =>
                {
                    InUndoHelper.RecordObject(SplineNode.SplineController, "Connect nodes");
                    (o as GameObject).GetComponent <InSplineNode>().ConnectTo(SplineNode);
                });

                //var a = new SerializedObject(SplineNode.SplineController)
                if (SplineNode.SplineController != null)
                {
                    expandedConnections = EditorGUILayout.Foldout(expandedConnections, "Connected to");

                    for (int i = 0; i < SplineNode.SplineController.Connections.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUI.enabled = false;
                        var conc = SplineNode.SplineController.Connections[i];
                        if (conc.NodeA == SplineNode)
                        {
                            EditorGUILayout.ObjectField(conc.NodeB, typeof(InSplineNode), true);
                            GUI.enabled = true;
                            if (GUILayout.Button("X", GUILayout.Width(20)))
                            {
                                InUndoHelper.RecordObject(SplineNode.SplineController, "Remove spline connection");
                                SplineNode.SplineController.RemoveConnections(conc);
                            }
                            EditorUtility.SetDirty(SplineNode.SplineController);
                        }
                        else if (conc.NodeB == SplineNode)
                        {
                            EditorGUILayout.ObjectField(conc.NodeA, typeof(InSplineNode), true);
                            GUI.enabled = true;
                            if (GUILayout.Button("X", GUILayout.Width(20)))
                            {
                                InUndoHelper.RecordObject(SplineNode.SplineController, "Remove spline connection");
                                SplineNode.SplineController.RemoveConnections(conc);
                            }
                            EditorUtility.SetDirty(SplineNode.SplineController);
                        }


                        EditorGUILayout.EndHorizontal();
                    }
                }
            }



            EditorGUILayout.Separator();
            bool delete = true;

            if (GUILayout.Button("Delete"))
            {
                InUndoHelper.DoInGroup(() =>
                {
            #if UNITY_4_1 || UNITY_4_2
                    Undo.RegisterSceneUndo("Combine nodes");
            #else
                    UndoAll("Delete node");
            #endif
                    foreach (var gameObject in Selection.gameObjects)
                    {
                        InUndoHelper.Destroy(gameObject);
                    }

                    delete = true;
                });
            }


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

                    GameObject go         = InUndoHelper.CreateGO(SplineNode.SplineController.gameObject.name + " Node");
                    go.transform.parent   = SplineNode.SplineController.transform;
                    go.transform.position = SplineNode.transform.position + SplineNode.transform.forward;
                    go.transform.position = SplineNode.transform.position;

                    var newNode = go.AddComponent <InSplineNode>();
                    newNode.SplineController = SplineNode.SplineController;
                    newNode.ConnectTo(SplineNode);
                    SplineNode.SplineController.Nodes.Add(newNode);

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

            if (EditorGUI.EndChangeCheck() && delete == false)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }