private void OnBecameInvisible()
 {
     this.RemovePicker();
     SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Remove(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
     PhysicsVisualizationSettings.DeinitDebugDraw();
     PhysicsDebugWindow.RepaintSceneAndGameViews();
 }
Exemple #2
0
        public void OnEnable()
        {
            m_Constraints = serializedObject.FindProperty("m_Constraints");
            m_ShowInfo.valueChanged.AddListener(Repaint);

            m_RequiresConstantRepaint = false;

            PhysicsDebugWindow.UpdateSelectionOnComponentAdd();
        }
        public static PhysicsDebugWindow ShowWindow()
        {
            PhysicsDebugWindow physicsDebugWindow = EditorWindow.GetWindow(typeof(PhysicsDebugWindow)) as PhysicsDebugWindow;

            if (physicsDebugWindow != null)
            {
                physicsDebugWindow.titleContent.text = "Physics Debug";
            }
            return(physicsDebugWindow);
        }
        void OnBecameInvisible()
        {
            if (m_SceneViewListenerAdded)
            {
                PhysicsVisualizationSettings.DeinitDebugDraw();
                m_SceneViewListenerAdded = false;
            }

            RepaintSceneAndGameViews();
            s_Window = null;
            PhysicsVisualizationSettings.isDebuggerActive = false;
        }
        void OnBecameVisible()
        {
            if (!m_SceneViewListenerAdded)
            {
                PhysicsVisualizationSettings.InitDebugDraw();
                m_SceneViewListenerAdded = true;
            }

            RepaintSceneAndGameViews();
            s_Window = this;
            PhysicsVisualizationSettings.isDebuggerActive = true;
        }
        public void OnEnable()
        {
            m_Mass       = serializedObject.FindProperty("m_Mass");
            m_Immovable  = serializedObject.FindProperty("m_Immovable");
            m_UseGravity = serializedObject.FindProperty("m_UseGravity");

            m_ImplicitCom     = serializedObject.FindProperty("m_ImplicitCom");
            m_ImplicitTensor  = serializedObject.FindProperty("m_ImplicitTensor");
            m_CenterOfMass    = serializedObject.FindProperty("m_CenterOfMass");
            m_InertiaTensor   = serializedObject.FindProperty("m_InertiaTensor");
            m_InertiaRotation = serializedObject.FindProperty("m_InertiaRotation");

            m_CollisionDetectionMode = serializedObject.FindProperty("m_CollisionDetectionMode");

            m_LinearDamping  = serializedObject.FindProperty("m_LinearDamping");
            m_AngularDamping = serializedObject.FindProperty("m_AngularDamping");
            m_JointFriction  = serializedObject.FindProperty("m_JointFriction");

            m_ParentAnchorPosition  = serializedObject.FindProperty("m_ParentAnchorPosition");
            m_ParentAnchorRotation  = serializedObject.FindProperty("m_ParentAnchorRotation");
            m_AnchorPosition        = serializedObject.FindProperty("m_AnchorPosition");
            m_AnchorRotation        = serializedObject.FindProperty("m_AnchorRotation");
            m_MatchAnchors          = serializedObject.FindProperty("m_MatchAnchors");
            m_ArticulationJointType = serializedObject.FindProperty("m_ArticulationJointType");

            m_LinearX = serializedObject.FindProperty("m_LinearX");
            m_LinearY = serializedObject.FindProperty("m_LinearY");
            m_LinearZ = serializedObject.FindProperty("m_LinearZ");
            m_SwingY  = serializedObject.FindProperty("m_SwingY");
            m_SwingZ  = serializedObject.FindProperty("m_SwingZ");
            m_Twist   = serializedObject.FindProperty("m_Twist");

            m_XDrive = serializedObject.FindProperty("m_XDrive");
            m_YDrive = serializedObject.FindProperty("m_YDrive");
            m_ZDrive = serializedObject.FindProperty("m_ZDrive");

            // Info foldout
            m_ShowInfo.valueChanged.AddListener(Repaint);

            m_RequiresConstantRepaint = false;

            PhysicsDebugWindow.UpdateSelectionOnComponentAdd();
        }
        private void DisplayControls(UnityEngine.Object o, SceneView view)
        {
            int dirtyCount = PhysicsVisualizationSettings.dirtyCount;

            PhysicsVisualizationSettings.showCollisionGeometry = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.showCollisionGeometry, PhysicsVisualizationSettings.showCollisionGeometry, new GUILayoutOption[0]);
            PhysicsVisualizationSettings.enableMouseSelect     = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.enableMouseSelect, PhysicsVisualizationSettings.enableMouseSelect, new GUILayoutOption[0]);
            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.useSceneCam = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.useSceneCam, PhysicsVisualizationSettings.useSceneCam, new GUILayoutOption[0]);
            }
            Vector2 mousePosition = Event.current.mousePosition;
            Rect    rect          = new Rect(0f, 17f, view.position.width, view.position.height - 17f);
            bool    flag          = rect.Contains(Event.current.mousePosition);
            bool    flag2         = PhysicsVisualizationSettings.showCollisionGeometry && PhysicsVisualizationSettings.enableMouseSelect && flag;

            if (flag2)
            {
                this.AddPicker();
                this.AddMouseLeaveListener();
                if (Event.current.type == EventType.MouseMove)
                {
                    PhysicsVisualizationSettings.UpdateMouseHighlight(HandleUtility.GUIPointToScreenPixelCoordinate(mousePosition));
                }
                if (Event.current.type == EventType.MouseDrag)
                {
                    PhysicsVisualizationSettings.ClearMouseHighlight();
                }
            }
            else
            {
                this.RemovePicker();
                PhysicsVisualizationSettings.ClearMouseHighlight();
            }
            if (dirtyCount != PhysicsVisualizationSettings.dirtyCount)
            {
                PhysicsDebugWindow.RepaintSceneAndGameViews();
            }
        }
Exemple #8
0
        public void OnEnable()
        {
            m_Mass        = serializedObject.FindProperty("m_Mass");
            m_Drag        = serializedObject.FindProperty("m_Drag");
            m_AngularDrag = serializedObject.FindProperty("m_AngularDrag");

            m_ImplicitCom     = serializedObject.FindProperty("m_ImplicitCom");
            m_CenterOfMass    = serializedObject.FindProperty("m_CenterOfMass");
            m_ImplicitTensor  = serializedObject.FindProperty("m_ImplicitTensor");
            m_InertiaTensor   = serializedObject.FindProperty("m_InertiaTensor");
            m_InertiaRotation = serializedObject.FindProperty("m_InertiaRotation");

            m_UseGravity         = serializedObject.FindProperty("m_UseGravity");
            m_IsKinematic        = serializedObject.FindProperty("m_IsKinematic");
            m_Interpolate        = serializedObject.FindProperty("m_Interpolate");
            m_CollisionDetection = serializedObject.FindProperty("m_CollisionDetection");
            m_Constraints        = serializedObject.FindProperty("m_Constraints");

            m_ShowInfo.valueChanged.AddListener(Repaint);

            m_RequiresConstantRepaint = false;

            PhysicsDebugWindow.UpdateSelectionOnComponentAdd();
        }
        private void OnGUI()
        {
            int dirtyCount = PhysicsVisualizationSettings.dirtyCount;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]);
            PhysicsVisualizationSettings.filterWorkflow = (PhysicsVisualizationSettings.FilterWorkflow)EditorGUILayout.EnumPopup(PhysicsVisualizationSettings.filterWorkflow, EditorStyles.toolbarPopup, new GUILayoutOption[]
            {
                GUILayout.Width(130f)
            });
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Reset", EditorStyles.toolbarButton, new GUILayoutOption[0]))
            {
                PhysicsVisualizationSettings.Reset();
            }
            EditorGUILayout.EndHorizontal();
            this.m_MainScrollPos = GUILayout.BeginScrollView(this.m_MainScrollPos, new GUILayoutOption[0]);
            PhysicsVisualizationSettings.FilterWorkflow filterWorkflow = PhysicsVisualizationSettings.filterWorkflow;
            string str  = (filterWorkflow != PhysicsVisualizationSettings.FilterWorkflow.ShowSelectedItems) ? "Hide " : "Show ";
            int    mask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(PhysicsVisualizationSettings.GetShowCollisionLayerMask(filterWorkflow));
            int    concatenatedLayersMask = EditorGUILayout.MaskField(GUIContent.Temp(str + "Layers", str + "selected layers"), mask, InternalEditorUtility.layers, new GUILayoutOption[0]);

            PhysicsVisualizationSettings.SetShowCollisionLayerMask(filterWorkflow, InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(concatenatedLayersMask));
            PhysicsVisualizationSettings.SetShowStaticColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Static Colliders", str + "collision geometry from Colliders that do not have a Rigidbody"), PhysicsVisualizationSettings.GetShowStaticColliders(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowTriggers(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Triggers", str + "collision geometry from Colliders that have 'isTrigger' enabled"), PhysicsVisualizationSettings.GetShowTriggers(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowRigidbodies(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Rigidbodies", str + "collision geometry from Rigidbodies"), PhysicsVisualizationSettings.GetShowRigidbodies(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowKinematicBodies(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Kinematic Bodies", str + "collision geometry from Kinematic Rigidbodies"), PhysicsVisualizationSettings.GetShowKinematicBodies(filterWorkflow), new GUILayoutOption[0]));
            PhysicsVisualizationSettings.SetShowSleepingBodies(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "Sleeping Bodies", str + "collision geometry from Sleeping Rigidbodies"), PhysicsVisualizationSettings.GetShowSleepingBodies(filterWorkflow), new GUILayoutOption[0]));
            this.m_FilterColliderTypesFoldout = EditorGUILayout.Foldout(this.m_FilterColliderTypesFoldout, "Collider Types");
            if (this.m_FilterColliderTypesFoldout)
            {
                EditorGUI.indentLevel++;
                float labelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 200f;
                PhysicsVisualizationSettings.SetShowBoxColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "BoxColliders", str + "collision geometry from BoxColliders"), PhysicsVisualizationSettings.GetShowBoxColliders(filterWorkflow), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowSphereColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "SphereColliders", str + "collision geometry from SphereColliders"), PhysicsVisualizationSettings.GetShowSphereColliders(filterWorkflow), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowCapsuleColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "CapsuleColliders", str + "collision geometry from CapsuleColliders"), PhysicsVisualizationSettings.GetShowCapsuleColliders(filterWorkflow), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.Convex, EditorGUILayout.Toggle(GUIContent.Temp(str + "MeshColliders (convex)", str + "collision geometry from convex MeshColliders"), PhysicsVisualizationSettings.GetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.Convex), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.NonConvex, EditorGUILayout.Toggle(GUIContent.Temp(str + "MeshColliders (concave)", str + "collision geometry from non-convex MeshColliders"), PhysicsVisualizationSettings.GetShowMeshColliders(filterWorkflow, PhysicsVisualizationSettings.MeshColliderType.NonConvex), new GUILayoutOption[0]));
                PhysicsVisualizationSettings.SetShowTerrainColliders(filterWorkflow, EditorGUILayout.Toggle(GUIContent.Temp(str + "TerrainColliders", str + "collision geometry from TerrainColliders"), PhysicsVisualizationSettings.GetShowTerrainColliders(filterWorkflow), new GUILayoutOption[0]));
                EditorGUIUtility.labelWidth = labelWidth;
                EditorGUI.indentLevel--;
            }
            GUILayout.Space(4f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            bool flag  = GUILayout.Button(str + "None", "MiniButton", new GUILayoutOption[0]);
            bool flag2 = GUILayout.Button(str + "All", "MiniButton", new GUILayoutOption[0]);

            if (flag || flag2)
            {
                PhysicsVisualizationSettings.SetShowForAllFilters(filterWorkflow, flag2);
            }
            GUILayout.EndHorizontal();
            this.m_ColorFoldout = EditorGUILayout.Foldout(this.m_ColorFoldout, "Colors");
            if (this.m_ColorFoldout)
            {
                EditorGUI.indentLevel++;
                PhysicsVisualizationSettings.staticColor       = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.staticColor, PhysicsVisualizationSettings.staticColor, false, true, false, PhysicsDebugWindow.Contents.pickerConfig, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.triggerColor      = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.triggerColor, PhysicsVisualizationSettings.triggerColor, false, true, false, PhysicsDebugWindow.Contents.pickerConfig, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.rigidbodyColor    = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.rigidbodyColor, PhysicsVisualizationSettings.rigidbodyColor, false, true, false, PhysicsDebugWindow.Contents.pickerConfig, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.kinematicColor    = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.kinematicColor, PhysicsVisualizationSettings.kinematicColor, false, true, false, PhysicsDebugWindow.Contents.pickerConfig, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.sleepingBodyColor = EditorGUILayout.ColorField(PhysicsDebugWindow.Contents.sleepingBodyColor, PhysicsVisualizationSettings.sleepingBodyColor, false, true, false, PhysicsDebugWindow.Contents.pickerConfig, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.colorVariance     = EditorGUILayout.Slider("Variation", PhysicsVisualizationSettings.colorVariance, 0f, 1f, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
            }
            this.m_RenderingFoldout = EditorGUILayout.Foldout(this.m_RenderingFoldout, "Rendering");
            if (this.m_RenderingFoldout)
            {
                EditorGUI.indentLevel++;
                PhysicsVisualizationSettings.baseAlpha       = 1f - EditorGUILayout.Slider("Transparency", 1f - PhysicsVisualizationSettings.baseAlpha, 0f, 1f, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.forceOverdraw   = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.forceOverdraw, PhysicsVisualizationSettings.forceOverdraw, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.viewDistance    = EditorGUILayout.FloatField(PhysicsDebugWindow.Contents.viewDistance, PhysicsVisualizationSettings.viewDistance, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.terrainTilesMax = EditorGUILayout.IntField(PhysicsDebugWindow.Contents.terrainTilesMax, PhysicsVisualizationSettings.terrainTilesMax, new GUILayoutOption[0]);
                EditorGUI.indentLevel--;
            }
            if (Unsupported.IsDeveloperBuild() || PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.devOptions, PhysicsVisualizationSettings.devOptions, new GUILayoutOption[0]);
            }
            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider("dotAlpha", PhysicsVisualizationSettings.dotAlpha, -1f, 1f, new GUILayoutOption[0]);
                PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.forceDot, PhysicsVisualizationSettings.forceDot, new GUILayoutOption[0]);
                Tools.hidden = EditorGUILayout.Toggle(PhysicsDebugWindow.Contents.toolsHidden, Tools.hidden, new GUILayoutOption[0]);
            }
            GUILayout.EndScrollView();
            if (dirtyCount != PhysicsVisualizationSettings.dirtyCount)
            {
                PhysicsDebugWindow.RepaintSceneAndGameViews();
            }
        }
 private void OnBecameVisible()
 {
     PhysicsVisualizationSettings.InitDebugDraw();
     SceneView.onSceneGUIDelegate = (SceneView.OnSceneFunc)Delegate.Combine(SceneView.onSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnSceneViewGUI));
     PhysicsDebugWindow.RepaintSceneAndGameViews();
 }