示例#1
0
        void Update()
        {
            var before = animatedTitleContent.text;

            AnimatedEditorTitleContent.Animate(ref animatedTitleContent, "StrataCuller");

            if (before != animatedTitleContent.text)//optimization, this editor is starting to bog with long reports
            {
                titleContent = animatedTitleContent;
                Repaint();
            }

            if (_assetScanRoutine != null)
            {
                _assetScanRoutine.MoveNext();
            }
        }
        void ShowCameras()
        {
            foreach (var cam in AllCameras)
            {
                if (cam == null)
                {
                    RefreshCameras();
                    return;
                }

                Color buttonColor = Color.white;

                if (PrefabUtility.GetPrefabType(cam.gameObject) == PrefabType.PrefabInstance)
                {
                    buttonColor = prefabBlue;
                }

                //darken if not an active game object
                if (!cam.gameObject.activeInHierarchy)
                {
                    buttonColor = Color.Lerp(buttonColor, Color.grey, 0.5f);
                }

                bool isSelected = (Selection.activeGameObject == cam.gameObject && Selection.activeGameObject != null);

                if (isSelected)
                {
                    GUI.color = Color.magenta;
                    GUILayout.BeginHorizontal(GUI.skin.GetStyle("Button"));
                }
                else
                {
                    GUILayout.BeginHorizontal();
                }

                GUI.color = buttonColor;
                string sourceName = cam.name;
                if (cam.enabled && cam.gameObject.activeInHierarchy)
                {
                    sourceName = AnimatedEditorTitleContent.GetSpinnyTriangle() + sourceName;
                }

                if (GUILayout.Button(sourceName, GUILayout.Width(overallWidth / 2)))
                {
                    Selection.activeGameObject = cam.gameObject;
                }

                string maskReport = "";
                for (int i = 0; i < 32; i++)
                {
                    if ((cam.cullingMask & (1 << i)) != 0)
                    {
                        maskReport += LayerMask.LayerToName(i) + "   ";
                    }
                }

                if (string.IsNullOrEmpty(maskReport))
                {
                    maskReport = "Nothing";
                }

                GUILayout.TextArea(maskReport);

                GUILayout.EndHorizontal();
            }

            GUI.color = Color.white;
        }
 void Update()
 {
     AnimatedEditorTitleContent.Animate(ref animatedTitleContent, "CamMonitor");
     titleContent = animatedTitleContent;
     Repaint();
 }
        void OnGUI()
        {
            if (wallpaper == null)
            {
                wallpaper = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                wallpaper.SetPixel(0, 0, new Color(0.4f, 0.25f, 0.25f));//dark EventMonitorRed
                wallpaper.Apply();
            }

            GUI.DrawTexture(new Rect(0, 0, position.width, position.height), wallpaper, ScaleMode.StretchToFill);

            if (!EditorApplication.isPlaying)
            {
                GUILayout.Label("Not Playing");
                return;
            }

            EditorGUIUtility.labelWidth = 70;

            GUILayout.BeginVertical(GUI.skin.GetStyle("Box"));
            groupEnabled = EditorGUILayout.Foldout(groupEnabled, "Enabled");
            if (!groupEnabled)
            {
                GUILayout.EndVertical();
                return;
            }

            if (ListenerTable == null)
            {
                ListenerTable = EventManager.ListenerTable;
            }

            if (tex == null)
            {
                tex = AnimatedEditorTitleContent.MakeTex(32, 32, new Color(1.0f, 1.0f, 1.0f, 0.1f));
            }

            GUILayout.BeginHorizontal();
            GUI.color = Color.white;
            GUILayout.Label("EVENTS", EditorStyles.boldLabel, GUILayout.Width(250));
            GUI.color = Color.yellow;
            GUILayout.Label("SUBSCRIBERS", EditorStyles.boldLabel);
            GUILayout.EndHorizontal();

            GUI.color      = Color.white;
            scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, true);

            GUI.skin.label.fontSize  = 10;
            GUI.skin.button.fontSize = 10;

            bool toggle = false;

            Color lightGrey = new Color(.7f, .7f, .7f);

            foreach (DictionaryEntry pair in ListenerTable)
            {
                toggle = !toggle;
                guiStyle.normal.background = toggle ? tex : null;

                GUI.color = lightGrey;
                GUILayout.BeginHorizontal(guiStyle);

                GUI.color = Color.white;
                if (GUILayout.Button(pair.Key.ToString(), GUILayout.Width(250)))
                {
                    Trigger(pair.Key.ToString());
                }

                ArrayList listenerList = pair.Value as ArrayList;

                GUILayout.BeginVertical();
                GUI.color = Color.yellow;

                for (var i = listenerList.Count - 1; i >= 0; --i)
                {
                    i = Mathf.Clamp(i, 0, listenerList.Count - 1);  //  Ran into a case once where i became out of range.  Band-aid fix.  I tried moving anything that modifies _listenerTable to outside this loop with no good results.
                    var listener = (IEventListener)listenerList[i];
                    GUILayout.Label(listener.ToString());
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                GUILayout.Space(7);
            }

            GUILayout.EndScrollView();

            GUILayout.EndVertical();

            EditorUtility.SetDirty(this);
        }
 public static void ShowWindow()
 {
     tex = AnimatedEditorTitleContent.MakeTex(32, 32, new Color(1.0f, 1.0f, 1.0f, 0.1f));
 }
示例#6
0
        void ShowAudioSources()
        {
            foreach (var src in AllAudioSources)
            {
                if (src == null)
                {
                    RefreshAudioSources();
                    return;
                }

                Color buttonColor = Color.white;

                if (PrefabUtility.GetPrefabType(src.gameObject) == PrefabType.PrefabInstance)
                {
                    buttonColor = prefabBlue;
                }

                //darken if not an active gameobject
                if (!src.gameObject.activeInHierarchy)
                {
                    buttonColor = Color.Lerp(buttonColor, Color.grey, 0.5f);
                }

                bool isSelected = (Selection.activeGameObject == src.gameObject && Selection.activeGameObject != null)
                                  ||
                                  (Selection.activeObject == src.clip && Selection.activeObject != null);

                if (isSelected)
                {
                    GUI.color = Color.green;
                    GUILayout.BeginHorizontal(GUI.skin.GetStyle("Box"));
                }
                else
                {
                    GUILayout.BeginHorizontal();
                }

                GUI.color = buttonColor;
                string sourceName = src.name;
                if (src.isPlaying)
                {
                    sourceName = AnimatedEditorTitleContent.GetSpinnyTriangle() + sourceName;
                }

                if (GUILayout.Button(sourceName, GUILayout.Width(overallWidth / 2)))
                {
                    Selection.activeGameObject = src.gameObject;
                }

                if (src.clip != null)
                {
                    string clipLabel = src.clip.name;


                    if (isSelected)
                    {
                        if (src.clip == currentPlayingClip || src.isPlaying)
                        {
                            GUI.color = Color.Lerp(Color.yellow, Color.red, 0.5f);
                            clipLabel = "Stop " + clipLabel;
                        }
                        else
                        {
                            clipLabel = "Play " + clipLabel;
                        }
                    }

                    if (GUILayout.Button(clipLabel))
                    {
                        if (isSelected)
                        {
                            if (Application.isPlaying)
                            {
                                if (!src.isPlaying)
                                {
                                    src.Play();
                                }
                                else
                                {
                                    src.Stop();
                                    _dirty = true;
                                }
                            }
                            else //edit mode
                            {
                                PlayOrStopClip(src.clip);
                            }
                        }
                        Selection.activeObject = src.clip;
                    }
                }
                else
                {
                    GUILayout.Label("");
                }

                GUILayout.EndHorizontal();
            }

            GUI.color = Color.white;
        }