Utility class for any prefab related operations.
public override void OnInspectorGUI() { if (this.m_ServerOnlyProperty == null) { this.m_Initialized = false; } this.Init(); this.serializedObject.Update(); if (this.m_ServerOnlyProperty.boolValue) { EditorGUILayout.PropertyField(this.m_ServerOnlyProperty, this.m_ServerOnlyLabel, new GUILayoutOption[0]); EditorGUILayout.LabelField("Local Player Authority cannot be set for server-only objects"); } else if (this.m_LocalPlayerAuthorityProperty.boolValue) { EditorGUILayout.LabelField("Server Only cannot be set for Local Player Authority objects"); EditorGUILayout.PropertyField(this.m_LocalPlayerAuthorityProperty, this.m_LocalPlayerAuthorityLabel, new GUILayoutOption[0]); } else { EditorGUILayout.PropertyField(this.m_ServerOnlyProperty, this.m_ServerOnlyLabel, new GUILayoutOption[0]); EditorGUILayout.PropertyField(this.m_LocalPlayerAuthorityProperty, this.m_LocalPlayerAuthorityLabel, new GUILayoutOption[0]); } this.serializedObject.ApplyModifiedProperties(); if (!Application.isPlaying) { return; } EditorGUILayout.Separator(); if (this.m_NetworkIdentity.observers != null && this.m_NetworkIdentity.observers.Count > 0) { this.m_ShowObservers = EditorGUILayout.Foldout(this.m_ShowObservers, "Observers"); if (this.m_ShowObservers) { ++EditorGUI.indentLevel; foreach (NetworkConnection observer in this.m_NetworkIdentity.observers) { GameObject gameObject = (GameObject)null; using (List <PlayerController> .Enumerator enumerator = observer.playerControllers.GetEnumerator()) { while (enumerator.MoveNext()) { PlayerController current = enumerator.Current; if (current != null) { gameObject = current.gameObject; break; } } } if ((bool)((Object)gameObject)) { EditorGUILayout.ObjectField("Connection " + (object)observer.connectionId, (Object)gameObject, typeof(GameObject), false, new GUILayoutOption[0]); } else { EditorGUILayout.TextField("Connection " + (object)observer.connectionId); } } --EditorGUI.indentLevel; } } if (PrefabUtility.GetPrefabType((Object)this.m_NetworkIdentity.gameObject) == PrefabType.Prefab || !this.m_NetworkIdentity.gameObject.activeSelf || (!this.m_NetworkIdentity.netId.IsEmpty() || !NetworkServer.active)) { return; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(this.m_SpawnLabel); if (GUILayout.Toggle(false, "Spawn", EditorStyles.miniButtonLeft, new GUILayoutOption[0])) { NetworkServer.Spawn(this.m_NetworkIdentity.gameObject); EditorUtility.SetDirty(this.target); } EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { if (m_ServerOnlyProperty == null) { m_Initialized = false; } Init(); serializedObject.Update(); if (m_ServerOnlyProperty.boolValue) { EditorGUILayout.PropertyField(m_ServerOnlyProperty, m_ServerOnlyLabel); EditorGUILayout.LabelField("Local Player Authority cannot be set for server-only objects"); } else if (m_LocalPlayerAuthorityProperty.boolValue) { EditorGUILayout.LabelField("Server Only cannot be set for Local Player Authority objects"); EditorGUILayout.PropertyField(m_LocalPlayerAuthorityProperty, m_LocalPlayerAuthorityLabel); } else { EditorGUILayout.PropertyField(m_ServerOnlyProperty, m_ServerOnlyLabel); EditorGUILayout.PropertyField(m_LocalPlayerAuthorityProperty, m_LocalPlayerAuthorityLabel); } serializedObject.ApplyModifiedProperties(); if (!Application.isPlaying) { return; } // Runtime actions below here EditorGUILayout.Separator(); if (m_NetworkIdentity.observers != null && m_NetworkIdentity.observers.Count > 0) { m_ShowObservers = EditorGUILayout.Foldout(m_ShowObservers, "Observers"); if (m_ShowObservers) { EditorGUI.indentLevel += 1; foreach (var o in m_NetworkIdentity.observers) { GameObject obj = null; foreach (var p in o.playerControllers) { if (p != null) { obj = p.gameObject; break; } } if (obj) { EditorGUILayout.ObjectField("Connection " + o.connectionId, obj, typeof(GameObject), false); } else { EditorGUILayout.TextField("Connection " + o.connectionId); } } EditorGUI.indentLevel -= 1; } } if (PrefabUtility.IsPartOfPrefabAsset(m_NetworkIdentity.gameObject)) { return; } if (m_NetworkIdentity.gameObject.activeSelf && m_NetworkIdentity.netId.IsEmpty() && NetworkServer.active) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(m_SpawnLabel); if (GUILayout.Toggle(false, "Spawn", EditorStyles.miniButtonLeft)) { NetworkServer.Spawn(m_NetworkIdentity.gameObject); EditorUtility.SetDirty(target); // preview window STILL doens't update immediately.. } EditorGUILayout.EndHorizontal(); } }
internal bool DrawInspector() { serializedObject.Update(); GameObject go = target as GameObject; // Don't let icon be null as it will create null reference exceptions. Texture2D icon = (Texture2D)(Styles.typelessIcon.image); // Leave iconContent to be default if multiple objects not the same type. if (m_AllOfSamePrefabType) { icon = PrefabUtility.GetIconForGameObject(go); } // Can't do this in OnEnable since it will cause Styles static initializer to be called and // access properties on EditorStyles static class before that one has been initialized. if (m_OpenPrefabContent == null) { if (targets.Length == 1) { GameObject originalSourceOrVariant = PrefabUtility.GetOriginalSourceOrVariantRoot((GameObject)target); if (originalSourceOrVariant != null) { m_OpenPrefabContent = new GUIContent( Styles.openPrefab.text, string.Format(Styles.openPrefab.tooltip, originalSourceOrVariant.name)); } } if (m_OpenPrefabContent == null) { m_OpenPrefabContent = new GUIContent(Styles.openPrefab.text); } } EditorGUILayout.BeginHorizontal(); Vector2 dropDownSize = EditorGUI.GetObjectIconDropDownSize(kIconSize, kIconSize); EditorGUI.ObjectIconDropDown(GUILayoutUtility.GetRect(dropDownSize.x, dropDownSize.y, GUILayout.ExpandWidth(false)), targets, true, icon, m_Icon); DrawPostIconContent(); using (new EditorGUI.DisabledScope(m_ImmutableSelf)) { EditorGUILayout.BeginVertical(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginHorizontal(GUILayout.Width(Styles.tagFieldWidth)); { GUILayout.FlexibleSpace(); // IsActive EditorGUI.PropertyField( GUILayoutUtility.GetRect(EditorStyles.toggle.padding.left, EditorGUIUtility.singleLineHeight, EditorStyles.toggle, GUILayout.ExpandWidth(false)), m_IsActive, GUIContent.none); } EditorGUILayout.EndHorizontal(); // Disable the name field of root GO in prefab asset using (new EditorGUI.DisabledScope(m_IsAsset && m_IsAssetRoot)) { // Name EditorGUILayout.DelayedTextField(m_Name, GUIContent.none, EditorStyles.boldTextField); } // Static flags toggle DoStaticToggleField(go); // Static flags dropdown DoStaticFlagsDropDown(go); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(EditorGUI.kControlVerticalSpacing); EditorGUILayout.BeginHorizontal(); { // Tag DoTagsField(go); EditorGUILayout.Space(EditorGUI.kDefaultSpacing, false); // Layer DoLayerField(go); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); // Prefab Toolbar if (EditorGUIUtility.comparisonViewMode == EditorGUIUtility.ComparisonViewMode.None) { EditorGUILayout.Space(EditorGUI.kControlVerticalSpacing); DoPrefabButtons(); } serializedObject.ApplyModifiedProperties(); return(true); }
private void DoPrefabButtons() { if (!m_IsPrefabInstanceAnyRoot || m_IsAsset) { return; } using (new EditorGUI.DisabledScope(m_PlayModeObjects)) { EditorGUILayout.BeginHorizontal(Styles.prefabButtonsHorizontalLayout); // Prefab information PrefabAssetType singlePrefabType = PrefabUtility.GetPrefabAssetType(target); PrefabInstanceStatus singleInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(target); GUIContent prefixLabel; if (targets.Length > 1) { prefixLabel = Styles.goTypeLabelMultiple; } else { prefixLabel = Styles.goTypeLabel[(int)singlePrefabType, (int)singleInstanceStatus]; } if (prefixLabel != null) { EditorGUILayout.BeginHorizontal(GUILayout.Width(kIconSize + Styles.tagFieldWidth)); GUILayout.FlexibleSpace(); if (m_IsDisconnected || m_IsMissing) { GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor; DoPrefixLabel(prefixLabel, EditorStyles.whiteLabel); GUI.contentColor = Color.white; } else { DoPrefixLabel(prefixLabel, EditorStyles.label); } EditorGUILayout.EndHorizontal(); } if (!m_IsMissing) { using (new EditorGUI.DisabledScope(targets.Length > 1)) { if (singlePrefabType == PrefabAssetType.Model) { // Open Model Prefab if (GUILayout.Button(Styles.openModel, EditorStyles.miniButtonLeft)) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); AssetDatabase.OpenAsset(asset); GUIUtility.ExitGUI(); } } else { // Open non-Model Prefab using (new EditorGUI.DisabledScope(m_ImmutableSourceAsset)) { if (GUILayout.Button(m_OpenPrefabContent, EditorStyles.miniButtonLeft)) { GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target); var prefabStageMode = PrefabStageUtility.GetPrefabStageModeFromModifierKeys(); PrefabStageUtility.OpenPrefab(AssetDatabase.GetAssetPath(asset), (GameObject)target, prefabStageMode, StageNavigationManager.Analytics.ChangeType.EnterViaInstanceInspectorOpenButton); GUIUtility.ExitGUI(); } } } } // Select prefab if (GUILayout.Button(Styles.selectString, EditorStyles.miniButtonRight)) { HashSet <GameObject> selectedAssets = new HashSet <GameObject>(); for (int i = 0; i < targets.Length; i++) { GameObject prefabGo = PrefabUtility.GetOriginalSourceOrVariantRoot(targets[i]); // Because of legacy prefab references we have to have this extra step // to make sure we ping the prefab asset correctly. // Reason is that scene files created prior to making prefabs CopyAssets // will reference prefabs as if they are serialized assets. Those references // works fine but we are not able to ping objects loaded directly from the asset // file, so we have to make sure we ping the metadata version of the prefab. var assetPath = AssetDatabase.GetAssetPath(prefabGo); selectedAssets.Add((GameObject)AssetDatabase.LoadMainAssetAtPath(assetPath)); } Selection.objects = selectedAssets.ToArray(); if (Selection.gameObjects.Length == 1) { EditorGUIUtility.PingObject(Selection.activeObject); } } // Should be EditorGUILayout.Space, except it does not have ExpandWidth set to false. // Maybe we can change that? GUILayoutUtility.GetRect(6, 6, GUILayout.ExpandWidth(false)); // Reserve space regardless of whether the button is there or not to avoid jumps in button sizes. Rect rect = GUILayoutUtility.GetRect(Styles.overridesContent, Styles.overridesDropdown); if (m_IsPrefabInstanceOutermostRoot) { if (EditorGUI.DropdownButton(rect, Styles.overridesContent, FocusType.Passive)) { if (targets.Length > 1) { PopupWindow.Show(rect, new PrefabOverridesWindow(targets.Select(e => (GameObject)e).ToArray())); } else { PopupWindow.Show(rect, new PrefabOverridesWindow((GameObject)target)); } GUIUtility.ExitGUI(); } } } EditorGUILayout.EndHorizontal(); } }
public void OnSceneDrag(SceneView sceneView) { GameObject go = target as GameObject; if (!PrefabUtility.IsPartOfPrefabAsset(go)) { return; } var prefabAssetRoot = go.transform.root.gameObject; Event evt = Event.current; switch (evt.type) { case EventType.DragUpdated: Scene destinationScene = sceneView.customScene.IsValid() ? sceneView.customScene : SceneManager.GetActiveScene(); if (dragObject == null) { if (!EditorApplication.isPlaying || EditorSceneManager.IsPreviewScene(destinationScene)) { dragObject = (GameObject)PrefabUtility.InstantiatePrefab(prefabAssetRoot, destinationScene); dragObject.name = go.name; } else { // Instatiate as regular GameObject in Play Mode so runtime logic // won't run into restrictions on restructuring Prefab instances. dragObject = Instantiate(prefabAssetRoot); SceneManager.MoveGameObjectToScene(dragObject, destinationScene); } dragObject.hideFlags = HideFlags.HideInHierarchy; } if (HandleUtility.ignoreRaySnapObjects == null) { HandleUtility.ignoreRaySnapObjects = dragObject.GetComponentsInChildren <Transform>(); } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; Vector3 point, normal; if (HandleUtility.PlaceObject(evt.mousePosition, out point, out normal)) { float offset = 0; if (Tools.pivotMode == PivotMode.Center) { float geomOffset = HandleUtility.CalcRayPlaceOffset(HandleUtility.ignoreRaySnapObjects, normal); if (geomOffset != Mathf.Infinity) { offset = Vector3.Dot(dragObject.transform.position, normal) - geomOffset; } } dragObject.transform.position = Matrix4x4.identity.MultiplyPoint(point + (normal * offset)); } else { dragObject.transform.position = HandleUtility.GUIPointToWorldRay(evt.mousePosition).GetPoint(10); } // Use prefabs original z position when in 2D mode if (sceneView.in2DMode) { Vector3 dragPosition = dragObject.transform.position; dragPosition.z = prefabAssetRoot.transform.position.z; dragObject.transform.position = dragPosition; } evt.Use(); break; case EventType.DragPerform: var stage = StageNavigationManager.instance.currentStage; if (stage is PrefabStage) { var prefabAssetThatIsAddedTo = AssetDatabase.LoadMainAssetAtPath(stage.assetPath); if (PrefabUtility.CheckIfAddingPrefabWouldResultInCyclicNesting(prefabAssetThatIsAddedTo, go)) { PrefabUtility.ShowCyclicNestingWarningDialog(); return; } } Transform parent = sceneView.customParentForDraggedObjects; string uniqueName = GameObjectUtility.GetUniqueNameForSibling(parent, dragObject.name); if (parent != null) { dragObject.transform.parent = parent; } dragObject.hideFlags = 0; Undo.RegisterCreatedObjectUndo(dragObject, "Place " + dragObject.name); EditorUtility.SetDirty(dragObject); DragAndDrop.AcceptDrag(); Selection.activeObject = dragObject; HandleUtility.ignoreRaySnapObjects = null; if (SceneView.mouseOverWindow != null) { SceneView.mouseOverWindow.Focus(); } if (!Application.IsPlaying(dragObject)) { dragObject.name = uniqueName; } dragObject = null; evt.Use(); break; case EventType.DragExited: if (dragObject) { UnityObject.DestroyImmediate(dragObject, false); HandleUtility.ignoreRaySnapObjects = null; dragObject = null; evt.Use(); } break; } }
void CalculatePrefabStatus() { m_PlayModeObjects = false; m_IsAsset = false; m_ImmutableSelf = false; m_ImmutableSourceAsset = false; m_IsDisconnected = false; m_IsMissing = false; m_IsPrefabInstanceAnyRoot = true; m_IsPrefabInstanceOutermostRoot = true; m_AllOfSamePrefabType = true; m_IsAssetRoot = false; PrefabAssetType firstType = PrefabUtility.GetPrefabAssetType(targets[0]); PrefabInstanceStatus firstStatus = PrefabUtility.GetPrefabInstanceStatus(targets[0]); m_OpenPrefabContent = null; foreach (var o in targets) { var go = (GameObject)o; PrefabAssetType type = PrefabUtility.GetPrefabAssetType(go); PrefabInstanceStatus status = PrefabUtility.GetPrefabInstanceStatus(go); if (type != firstType || status != firstStatus) { m_AllOfSamePrefabType = false; } if (Application.IsPlaying(go)) { m_PlayModeObjects = true; } if (!PrefabUtility.IsAnyPrefabInstanceRoot(go)) { m_IsPrefabInstanceAnyRoot = false; // Conservative is false if any is false } if (!m_IsPrefabInstanceAnyRoot || !PrefabUtility.IsOutermostPrefabInstanceRoot(go)) { m_IsPrefabInstanceOutermostRoot = false; // Conservative is false if any is false } if (PrefabUtility.IsPartOfPrefabAsset(go)) { m_IsAsset = true; // Conservative is true if any is true if (go.transform.parent == null) { m_IsAssetRoot = true; } } if (m_IsAsset && PrefabUtility.IsPartOfImmutablePrefab(go)) { m_ImmutableSelf = true; // Conservative is true if any is true } GameObject originalSourceOrVariant = PrefabUtility.GetOriginalSourceOrVariantRoot(go); if (originalSourceOrVariant != null && PrefabUtility.IsPartOfImmutablePrefab(originalSourceOrVariant)) { m_ImmutableSourceAsset = true; // Conservative is true if any is true } if (PrefabUtility.IsDisconnectedFromPrefabAsset(go)) { m_IsDisconnected = true; } if (PrefabUtility.IsPrefabAssetMissing(go)) { m_IsMissing = true; } } }
public static bool ResetToPrefabState(Object source) { return(PrefabUtility.ResetToPrefabState(source)); }
public static GameObject ReplacePrefab(GameObject go, Object targetPrefab) { return(PrefabUtility.ReplacePrefab(go, targetPrefab, ReplacePrefabOptions.Default)); }
public static Object GetPrefabParent(Object source) { return(PrefabUtility.GetCorrespondingObjectFromSource(source)); }
public static GameObject FindPrefabRoot(GameObject source) { return(PrefabUtility.FindPrefabRoot(source)); }
public static PrefabType GetPrefabType(Object target) { return(PrefabUtility.GetPrefabType(target)); }
public static bool ReconnectToLastPrefab(GameObject go) { return(PrefabUtility.ReconnectToLastPrefab(go)); }
public static Object CreateEmptyPrefab(string path) { return(PrefabUtility.CreateEmptyPrefab(path)); }
internal static UInt64 GetOrGenerateFileIDHint(UnityEngine.Object obj) { UInt64 fileID = Unsupported.GetFileIDHint(obj); if (fileID == 0) { // GenerateFileIDHint only work on saved nested prefabs instances. var instanceHandle = PrefabUtility.GetPrefabInstanceHandle(obj); if (instanceHandle != null) { bool isPrefabInstanceSaved = Unsupported.GetFileIDHint(instanceHandle) != 0; if (isPrefabInstanceSaved && PrefabUtility.IsPartOfNonAssetPrefabInstance(obj) && PrefabUtility.GetPrefabAssetType(obj) != PrefabAssetType.MissingAsset) { fileID = Unsupported.GenerateFileIDHint(obj); } } } return(fileID); }
internal static void DisplayObjectContextMenu(Rect position, Object[] context, int contextUserData) { // Don't show context menu if we're inside the side-by-side diff comparison. if (EditorGUIUtility.comparisonViewMode != EditorGUIUtility.ComparisonViewMode.None) { return; } Vector2 temp = GUIUtility.GUIToScreenPoint(new Vector2(position.x, position.y)); position.x = temp.x; position.y = temp.y; GenericMenu pm = new GenericMenu(); if (context != null && context.Length == 1 && context[0] is Component) { Object targetObject = context[0]; Component targetComponent = (Component)targetObject; // Do nothing if component is not on a prefab instance. if (PrefabUtility.GetCorrespondingConnectedObjectFromSource(targetComponent.gameObject) == null) { } // Handle added component. else if (PrefabUtility.GetCorrespondingObjectFromSource(targetObject) == null && targetComponent != null) { GameObject instanceGo = targetComponent.gameObject; PrefabUtility.HandleApplyRevertMenuItems( "Added Component", instanceGo, (menuItemContent, sourceGo) => { TargetChoiceHandler.ObjectInstanceAndSourcePathInfo info = new TargetChoiceHandler.ObjectInstanceAndSourcePathInfo(); info.instanceObject = targetComponent; info.assetPath = AssetDatabase.GetAssetPath(sourceGo); GameObject rootObject = PrefabUtility.GetRootGameObject(sourceGo); if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(instanceGo)) { pm.AddDisabledItem(menuItemContent); } else { pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabAddedComponent, info); } }, (menuItemContent) => { pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabAddedComponent, targetComponent); } ); } else { SerializedObject so = new SerializedObject(targetObject); SerializedProperty property = so.GetIterator(); bool hasPrefabOverride = false; while (property.Next(property.hasChildren)) { if (property.isInstantiatedPrefab && property.prefabOverride && !property.isDefaultOverride) { hasPrefabOverride = true; break; } } // Handle modified component. if (hasPrefabOverride) { bool defaultOverrides = PrefabUtility.IsObjectOverrideAllDefaultOverridesComparedToAnySource(targetObject); PrefabUtility.HandleApplyRevertMenuItems( "Modified Component", targetObject, (menuItemContent, sourceObject) => { TargetChoiceHandler.ObjectInstanceAndSourcePathInfo info = new TargetChoiceHandler.ObjectInstanceAndSourcePathInfo(); info.instanceObject = targetObject; info.assetPath = AssetDatabase.GetAssetPath(sourceObject); GameObject rootObject = PrefabUtility.GetRootGameObject(sourceObject); if (!PrefabUtility.IsPartOfPrefabThatCanBeAppliedTo(rootObject) || EditorUtility.IsPersistent(targetObject)) { pm.AddDisabledItem(menuItemContent); } else { pm.AddItem(menuItemContent, false, TargetChoiceHandler.ApplyPrefabObjectOverride, info); } }, (menuItemContent) => { pm.AddItem(menuItemContent, false, TargetChoiceHandler.RevertPrefabObjectOverride, targetObject); }, defaultOverrides ); } } } pm.ObjectContextDropDown(position, context, contextUserData); ResetMouseDown(); }
public override void OnInspectorGUI() { var body = target as Rigidbody2D; serializedObject.Update(); EditorGUILayout.PropertyField(m_BodyType); EditorGUILayout.PropertyField(m_Material); // Provide the user some information when simulation is turned off. EditorGUILayout.PropertyField(m_Simulated); if (!m_Simulated.boolValue && !m_Simulated.hasMultipleDifferentValues) { EditorGUILayout.HelpBox("The body has now been taken out of the simulation along with any attached colliders, joints or effectors.", MessageType.Info); } // Can only multi-edit if we have the same body-type. if (m_BodyType.hasMultipleDifferentValues) { EditorGUILayout.HelpBox("Cannot edit properties that are body type specific when the selection contains different body types.", MessageType.Info); } else { // Non-static options. m_ShowIsStatic.target = body.bodyType != RigidbodyType2D.Static; if (EditorGUILayout.BeginFadeGroup(m_ShowIsStatic.faded)) { // Kinematic options. m_ShowIsKinematic.target = body.bodyType != RigidbodyType2D.Kinematic; if (EditorGUILayout.BeginFadeGroup(m_ShowIsKinematic.faded)) { // Collider Mass. EditorGUILayout.PropertyField(m_UseAutoMass); // Only show mass property if selected objects have the same useAutoMass value. if (!m_UseAutoMass.hasMultipleDifferentValues) { // If we're using auto-mass but either the object is part of a prefab parent or is not active then we cannot show the calculated mass value. if (m_UseAutoMass.boolValue && targets.Any(x => PrefabUtility.IsPartOfPrefabAsset(x) || !(x as Rigidbody2D).gameObject.activeInHierarchy)) { EditorGUILayout.HelpBox("The auto mass value cannot be displayed for a prefab or if the object is not active. The value will be calculated for a prefab instance and when the object is active.", MessageType.Info); } else { EditorGUI.BeginDisabledGroup(body.useAutoMass); EditorGUILayout.PropertyField(m_Mass); EditorGUI.EndDisabledGroup(); } } EditorGUILayout.PropertyField(m_LinearDrag); EditorGUILayout.PropertyField(m_AngularDrag); EditorGUILayout.PropertyField(m_GravityScale); } EditorGUILayout.EndFadeGroup(); if (!m_ShowIsKinematic.target) { EditorGUILayout.PropertyField(m_UseFullKinematicContacts); } EditorGUILayout.PropertyField(m_CollisionDetection); EditorGUILayout.PropertyField(m_SleepingMode); EditorGUILayout.PropertyField(m_Interpolate); if (targets.Any(x => (x as Rigidbody2D).interpolation != RigidbodyInterpolation2D.None)) { if (Physics2D.simulationMode == SimulationMode2D.Update) { EditorGUILayout.HelpBox("The physics simulation mode is set to run per-frame. Any interpolation mode will be ignored and can be set to 'None'.", MessageType.Info); } if (Physics2D.simulationMode == SimulationMode2D.Script) { EditorGUILayout.HelpBox("The physics simulation mode is set to run manually in the scripts. Some or all selected Rigidbody2D are using an interpolation mode other than 'None' which will be executed per-frame. If the manual simulation is being run per-frame then the interpolation mode should be set to 'None'.", MessageType.Info); } } GUILayout.BeginHorizontal(); m_Constraints.isExpanded = EditorGUILayout.Foldout(m_Constraints.isExpanded, "Constraints", true); GUILayout.EndHorizontal(); var constraints = (RigidbodyConstraints2D)m_Constraints.intValue; if (m_Constraints.isExpanded) { EditorGUI.indentLevel++; ToggleFreezePosition(constraints, m_FreezePositionLabel, 0, 1); ToggleFreezeRotation(constraints, m_FreezeRotationLabel, 2); EditorGUI.indentLevel--; } } EditorGUILayout.EndFadeGroup(); } serializedObject.ApplyModifiedProperties(); ShowBodyInfoProperties(); }
public static Object InstantiatePrefab(Object target) { return(PrefabUtility.InstantiatePrefab(target)); }