public static void ToggleEditorPhysicsSelected() { #if UNITY_2017_1_OR_NEWER if (currentEditorPhysics != null) { currentEditorPhysics.Stop(); return; } List <Rigidbody> bodies = new List <Rigidbody>(); List <GameObject> withoutBodies = new List <GameObject>(); foreach (var gameObject in Selection.gameObjects) { var rb = gameObject.GetComponentsInChildren <Rigidbody>(); if (rb.Length == 0) { withoutBodies.Add(gameObject); } bodies.AddRange(rb); } currentEditorPhysics = new EditorPhysicsSceneCommand(bodies.ToArray(), withoutBodies.ToArray()); MonkeyEditorUtils.AddSceneCommand(currentEditorPhysics); #endif }
public static void ToggleEditorPhysics() { #if UNITY_2017_1_OR_NEWER if (currentEditorPhysics != null) { currentEditorPhysics.Stop(); return; } currentEditorPhysics = new EditorPhysicsSceneCommand(Object.FindObjectsOfType <Rigidbody>()); MonkeyEditorUtils.AddSceneCommand(currentEditorPhysics); #endif }