#pragma warning restore 649 public override bool CreateGameObject(out GameObject createdObj, Transform parentTransform) { if (m_Prefab == null) { createdObj = null; return(false); } MARSSession.EnsureRuntimeState(); var objName = GameObjectUtility.GetUniqueNameForSibling(null, m_ObjectName); createdObj = Instantiate(m_Prefab); MarsWorldScaleModule.ScaleChildren(createdObj.transform); foreach (var colorComponent in createdObj.GetComponentsInChildren <IHasEditorColor>()) { colorComponent.SetNewColor(true, true); } createdObj.name = objName; Undo.RegisterCreatedObjectUndo(createdObj, $"Create {objName}"); Selection.activeGameObject = createdObj; return(true); }
#pragma warning restore 649 public override bool CreateGameObject(out GameObject createdObj, Transform parentTransform = null) { MARSSession.EnsureRuntimeState(); createdObj = null; SimulationView activeView = SimulationView.ActiveSimulationView as SimulationView; if (activeView != null) { activeView.EnvironmentSceneActive = true; } Tools.current = Tool.Move; GameObject markerGO; using (var undoBlock = new UndoBlock("Synthetic Marker Creation")) { var imageMarkerParent = GetOrGenerateUniqueParent(k_SimulatedMarkersParentName); if (imageMarkerParent == null) { Debug.LogWarning("Unable to create synthetic marker."); return(false); } var syntheticMarker = CreateSyntheticMarker(); var markerTransform = syntheticMarker.transform; markerTransform.parent = imageMarkerParent; // Zero out position and rotation, leave scale in case the user is working with other scale. markerTransform.localPosition = Vector3.zero; markerTransform.localRotation = Quaternion.identity; markerTransform.name = GameObjectUtility.GetUniqueNameForSibling(imageMarkerParent, m_ObjectName); markerGO = markerTransform.gameObject; undoBlock.RegisterCreatedObject(markerGO); Selection.activeTransform = markerTransform; var initialScale = Vector2.one * MarsWorldScaleModule.GetWorldScale(); syntheticMarker.UpdateMarkerSize(initialScale); markerTransform.localScale = new Vector3(1, 0.01f, 1); createdObj = markerTransform.gameObject; } return(true); }
public override bool CreateGameObject() { if (m_Prefab == null) { return(false); } MARSSession.EnsureRuntimeState(); var objName = GameObjectUtility.GetUniqueNameForSibling(null, m_ButtonName); var go = Instantiate(m_Prefab); MarsWorldScaleModule.ScaleChildren(go.transform); foreach (var colorComponent in go.GetComponentsInChildren <IHasEditorColor>()) { colorComponent.SetNewColor(true, true); } go.name = objName; Undo.RegisterCreatedObjectUndo(go, $"Create {objName}"); Selection.activeGameObject = go; return(true); }