예제 #1
0
    private void DrawCameraList(IMDrawManager component, bool isPlaying)
    {
        if (!isPlaying)         // Unity isn't running
        {
            return;
        }

        Space();

        List <IMDrawCamera> cameraList = IMDrawCamera.GetCameraList();

        if (cameraList.Count > 0)
        {
            IMDrawCamera child;

            for (int index = 0; index < cameraList.Count; ++index)
            {
                child = cameraList[index];

                if (child == null)
                {
                    continue;
                }

                EditorGUILayout.BeginHorizontal();

                if (isPlaying)
                {
                    // Indicate if this camera is the current target
                    if (child == IMDrawManager.TargetCamera)
                    {
                        GUILayout.Label("►", EditorStyles.whiteLabel, GUILayout.Width(15f));
                    }
                    else
                    {
                        GUILayout.Space(20f);
                    }
                }

                GUILayout.Label(string.Format("Priority:{0}", child.Priority), EditorStyles.whiteLabel, GUILayout.Width(100f));

                GUILayout.Label(child != null ? child.name : "null", EditorStyles.whiteLabel);

                if (IMDrawManager.TargetCamera != child)
                {
                    if (GUILayout.Button("Set as target", GUILayout.Width(90f)))
                    {
                        IMDrawManager.TargetCamera = child;
                    }
                }

                EditorGUILayout.EndHorizontal();
            }
        }
        else
        {
            GUILayout.Label("No active IMDrawCamera components found.", EditorStyles.whiteLabel);
        }
    }
예제 #2
0
    private void DisplayErrors(IMDrawManager component)
    {
        // Warnings and errors
        m_SB.Length = 0;

        if (!component.isActiveAndEnabled)
        {
            LogHelpBox("IMDrawManager is disabled!");
        }

        if (component.IsMeshMissing)
        {
            LogHelpBox("Mesh reference is missing!");
        }

        if (m_SB.Length > 0)
        {
            Space();

            HelpBox(m_SB.ToString(), MessageType.Error);
        }
    }
예제 #3
0
 private static void Unregister(IMDrawManager manager)
 {
     s_IMDrawManagerList.Remove(manager);
     s_ActiveManager = s_IMDrawManagerList.Count > 0 ? s_IMDrawManagerList[0] : null;         // Ensure the active manager is valid
 }
예제 #4
0
    public override void OnInspectorGUI()
    {
        bool isPlaying = Application.isPlaying;

        IMDrawManager component = (IMDrawManager)target;

        if (isPlaying)
        {
            if (IMDrawManager.Instance == null)
            {
                HelpBox("There are no active IMDrawManagers in this scene!", MessageType.Error);
                return;
            }
            else if (IMDrawManager.Instance != component)
            {
                HelpBox("There are multiple IMDrawManagers in this scene!", MessageType.Error);
                return;
            }
        }

        serializedObject.Update();

        DrawPanel(m_Title, TextAnchor.MiddleCenter);

        DisplayErrors(component);

        if (m_ExecutionOrder != -10000)
        {
            if (!isPlaying)
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.HelpBox("This script must be FIRST in the execution order!", MessageType.Warning);

                if (GUILayout.Button("FIX", GUILayout.Width(100f), GUILayout.Height(40f)))
                {
                    SetExecutionOrder(-10000);
                    m_ExecutionOrder = -10000;
                }

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.HelpBox("This script must be FIRST in the execution order!", MessageType.Warning);
            }
        }

        DrawCameraList(component, isPlaying);

        Space();

        if (Foldout("Meshes", ref m_MeshFoldout))
        {
            GUI.enabled           = !isPlaying;
            EditorGUI.indentLevel = EditorGUI.indentLevel + 1;
            PropertyField(m_MeshQuadProperty, "Quad");
            PropertyField(m_MeshBoxProperty, "Box");
            PropertyField(m_MeshPyramidProperty, "Pyramid");
            PropertyField(m_MeshRhombusProperty, "Rhombus");
            PropertyField(m_MeshDiscProperty, "Disc");
            PropertyField(m_MeshSphereProperty, "Sphere");
            PropertyField(m_MeshConeProperty, "Cone");
            PropertyField(m_MeshCapsuleBodyProperty, "Capsule body");
            PropertyField(m_MeshCapsuleCapProperty, "Capsule cap");
            PropertyField(m_MeshCylinderProperty, "Cylinder");
            EditorGUI.indentLevel = EditorGUI.indentLevel - 1;
            GUI.enabled           = true;
        }

        if (component.IsMeshMissing)
        {
            GUILayout.Space(4f);

            if (GUILayout.Button("Assign missing meshes as default"))
            {
                AssignMissingMeshAsDefault(m_MeshQuadProperty, "IMDrawQuad");
                AssignMissingMeshAsDefault(m_MeshBoxProperty, "IMDrawBox");
                AssignMissingMeshAsDefault(m_MeshPyramidProperty, "IMDrawPyramid");
                AssignMissingMeshAsDefault(m_MeshRhombusProperty, "IMDrawRhombus");
                AssignMissingMeshAsDefault(m_MeshDiscProperty, "IMDrawDisc");
                AssignMissingMeshAsDefault(m_MeshSphereProperty, "IMDrawSphere");
                AssignMissingMeshAsDefault(m_MeshConeProperty, "IMDrawCone");
                AssignMissingMeshAsDefault(m_MeshCapsuleBodyProperty, "IMDrawCapsuleBody");
                AssignMissingMeshAsDefault(m_MeshCapsuleCapProperty, "IMDrawCapsuleCap");
                AssignMissingMeshAsDefault(m_MeshCylinderProperty, "IMDrawCylinder");
            }
        }

        if (isPlaying && IMDrawManager.TargetCamera != null)
        {
            Space();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(string.Format("Flush Target: {0}", IMDrawManager.TargetCamera.name)))
            {
                component.Flush();
            }

            if (GUILayout.Button("Flush All"))
            {
                component.FlushAll();
            }

            EditorGUILayout.EndHorizontal();
        }

        Space();

        serializedObject.ApplyModifiedProperties();
    }
예제 #5
0
 private static void Register(IMDrawManager manager)
 {
     s_IMDrawManagerList.Add(manager);
     s_ActiveManager = s_IMDrawManagerList[0];
 }