private bool Begin(IEnumerable <GameObject> targetObjects) { if (_state != State.Inactive || SharedSettings == null || SharedHotkeys == null || targetObjects == null) { return(false); } _targetObjects = new List <GameObject>(targetObjects); if (_targetObjects.Count == 0) { return(false); } _targetParents = GameObjectEx.FilterParentsOnly(_targetObjects); if (!CalculateTargetAABB() || !IdentifySitSurface()) { _targetObjects.Clear(); _targetParents.Clear(); return(false); } _state = State.Active; _preTargetTransformSnapshots = LocalTransformSnapshot.GetSnapshotCollection(_targetParents); if (SessionBegin != null) { SessionBegin(); } return(true); }
public override void OnGizmoRender(Camera camera) { bool multipleRenderCams = RTGizmosEngine.Get.NumRenderCameras > 1; if (multipleRenderCams) { _midCap.ApplyZoomFactor(camera); _axesSliders.ApplyZoomFactor(camera); _dblSliders.ApplyZoomFactor(camera); if (_multiAxisScaleMode == GizmoMultiAxisScaleMode.DoubleAxis) { PlaceDblSlidersInSliderPlanes(camera); } } var sortedSliders = _axesSliders.GetRenderSortedSliders(camera); foreach (var slider in sortedSliders) { slider.Render(camera); } _xySlider.Render(camera); _yzSlider.Render(camera); _zxSlider.Render(camera); _midCap.Render(camera); if (LookAndFeel3D.IsScaleGuideVisible && Gizmo.IsDragged && OwnsHandle(Gizmo.DragHandleId)) { _scaleGuide.Render(GameObjectEx.FilterParentsOnly(_scaleGuideTargetObjects), camera); } }
public void SetTargetCamera(Camera camera) { if (camera == null) { return; } if (Application.isPlaying) { if (IsDoingFocus || IsDoingProjectionSwitch || IsDoingRotationSwitch) { return; } _targetCamera = camera; _targetTransform = camera.transform; _fieldOfView = camera.fieldOfView; SetFocusPoint(GetFocusPoint()); AdjustOrthoSizeForFocusPt(); _isObjectVisibilityDirty = true; } #if UNITY_EDITOR else { if (GameObjectEx.IsSceneObject(camera.gameObject)) { _targetCamera = camera; _fieldOfView = camera.fieldOfView; } } #endif }
public override void OnGizmoRender(Camera camera) { bool multipleRenderCams = RTGizmosEngine.Get.NumRenderCameras > 1; if (multipleRenderCams) { _mvAxesSliders.ApplyZoomFactor(camera); if (!_isMvVertexSnapEnabled && !_is2DModeEnabled) { _mvDblSliders.ApplyZoomFactor(camera); PlaceMvDblSlidersInSliderPlanes(camera); } Update2DGizmoPosition(); if (_is2DModeEnabled) { Update2DModeHandlePositions(); } _rtMidCap.ApplyZoomFactor(camera); _rtAxesSliders.ApplyZoomFactor(camera); if (_rtCamLookSlider.IsBorderVisible) { UpdateRtCamLookSlider(camera); } _scMidCap.ApplyZoomFactor(camera); } _rtXSlider.Render(camera); _rtYSlider.Render(camera); _rtZSlider.Render(camera); _rtMidCap.Render(camera); var sortedSliders = _mvAxesSliders.GetRenderSortedSliders(camera); foreach (var slider in sortedSliders) { slider.Render(camera); } _rtCamLookSlider.Render(camera); _mvXYSlider.Render(camera); _mvYZSlider.Render(camera); _mvZXSlider.Render(camera); _scMidCap.Render(camera); _mvVertSnapCap.Render(camera); _mv2DModeSliders.Render(camera); _mv2DModeDblSlider.Render(camera); if (LookAndFeel3D.IsScScaleGuideVisible && Gizmo.IsDragged && IsScaleHandle(Gizmo.DragHandleId)) { _scScaleGuide.Render(GameObjectEx.FilterParentsOnly(_scScaleGuideTargetObjects), camera); } }
private bool IdentifyTargetParents(IEnumerable <GameObject> targetObjects) { _targetParents = GameObjectEx.FilterParentsOnly(targetObjects); if (_targetParents == null || _targetParents.Count == 0) { return(false); } return(true); }
public void SetExtrudeTargets(IEnumerable <GameObject> extrudeTargets) { if (extrudeTargets == null) { _targetParents.Clear(); _boxSize = Vector3.zero; return; } _targetParents = GameObjectEx.FilterParentsOnly(extrudeTargets); FitBoxToTargets(); }
private void OnObjectSelectionChanged(ObjectSelectionChangedEventArgs args) { if (args.SelectReason != ObjectSelectReason.None) { if (args.SelectReason == ObjectSelectReason.Undo || args.SelectReason == ObjectSelectReason.Redo) { _pivotObject = args.UndoRedoSnapshot.GizmosSnapshot.PivotObject; } else if (args.SelectReason == ObjectSelectReason.MultiSelect || args.SelectReason == ObjectSelectReason.MultiSelectAppend) { if (_pivotObject == null) { _pivotObject = GameObjectEx.FilterParentsOnly(args.ObjectsWhichWereSelected)[0]; } } else { if (args.NumObjectsSelected != 0) { _pivotObject = GameObjectEx.FilterParentsOnly(args.ObjectsWhichWereSelected)[0]; } else { _pivotObject = null; } } } else if (args.DeselectReason != ObjectDeselectReason.None) { if (args.DeselectReason == ObjectDeselectReason.Undo || args.DeselectReason == ObjectDeselectReason.Redo) { _pivotObject = args.UndoRedoSnapshot.GizmosSnapshot.PivotObject; } else if (RTObjectSelection.Get.NumSelectedObjects != 0) { if (!RTObjectSelection.Get.IsObjectSelected(_pivotObject)) { _pivotObject = GameObjectEx.FilterParentsOnly(_targetObjectCollection)[0]; } } else { _pivotObject = null; } } OnTargetObjectGroupUpdated(); }
public static ObjectAlign.Result AlignToWorldPlane(IEnumerable <GameObject> gameObjects, Plane alignmentPlane) { var parents = GameObjectEx.FilterParentsOnly(gameObjects); if (parents.Count == 0) { return(Result.Err_NoObjects); } AlignRootsToPlane(parents, alignmentPlane); return(Result.Success); }
private void OnPreSelectCustomize(ObjectPreSelectCustomizeInfo customizeInfo, List <GameObject> toBeSelected) { if (IgnoreObjectGroups) { List <GameObject> roots = GameObjectEx.GetRoots(toBeSelected); if (roots.Count == 0) { return; } List <GameObject> selectThese = new List <GameObject>(roots.Count * 10); foreach (var root in roots) { selectThese.AddRange(root.GetAllChildrenAndSelf()); } customizeInfo.SelectThese(selectThese); } else { HashSet <GameObject> selectedObjects = new HashSet <GameObject>(); foreach (var gameObj in toBeSelected) { // If this is an object group, ignore it if (RTObjectGroupDb.Get.IsGroup(gameObj)) { continue; } // Now move to the furthest parent up the hierarchy which is not an object group and // select it and all its children. Transform parentTransform = GetFurthestParentNotGroup(gameObj); // Store the parent and all its children var allObjectsInHierarchy = parentTransform.gameObject.GetAllChildrenAndSelf(); foreach (var hierarchyObject in allObjectsInHierarchy) { selectedObjects.Add(hierarchyObject); } } // Select the objects customizeInfo.SelectThese(selectedObjects); } }
private bool IdentifyGrabTargets(IEnumerable <GameObject> targetObjects) { _targetParents = GameObjectEx.FilterParentsOnly(targetObjects); if (_targetParents == null || _targetParents.Count == 0) { return(false); } _grabTargets.Clear(); foreach (GameObject targetObject in _targetParents) { if (targetObject.HierarchyHasObjectsOfType(GameObjectType.Terrain)) { continue; } _grabTargets.Add(new GrabTarget(targetObject)); } return(_grabTargets.Count != 0); }
private void OnPreDeselectCustomize(ObjectPreDeselectCustomizeInfo customizeInfo, List <GameObject> toBeDeselected) { if (IgnoreObjectGroups) { List <GameObject> roots = GameObjectEx.GetRoots(toBeDeselected); if (roots.Count == 0) { return; } List <GameObject> deselectThese = new List <GameObject>(roots.Count * 10); foreach (var root in roots) { deselectThese.AddRange(root.GetAllChildrenAndSelf()); } customizeInfo.DeselectThese(deselectThese); } else { HashSet <GameObject> deselectedObjects = new HashSet <GameObject>(); foreach (var gameObj in toBeDeselected) { if (RTObjectGroupDb.Get.IsGroup(gameObj)) { continue; } Transform parentTransform = GetFurthestParentNotGroup(gameObj); var allObjectsInHierarchy = parentTransform.gameObject.GetAllChildrenAndSelf(); foreach (var hierarchyObject in allObjectsInHierarchy) { deselectedObjects.Add(hierarchyObject); } } customizeInfo.DeselectThese(deselectedObjects); } }
private List <GameObject> GetTransformableParentObjects() { List <GameObject> targetParents = GameObjectEx.FilterParentsOnly(_targetObjects); List <GameObject> transformableParents = new List <GameObject>(); foreach (var parent in targetParents) { IRTTransformGizmoListener transformGizmoListener = parent.GetComponent <IRTTransformGizmoListener>(); if (transformGizmoListener != null && !transformGizmoListener.OnCanBeTransformed(Gizmo)) { continue; } if (Settings.IsLayerTransformable(parent.layer) && Settings.IsObjectTransformable(parent)) { transformableParents.Add(parent); } } return(transformableParents); }
public DuplicateObjectsAction(List <GameObject> rootsToDuplicate) { _rootsToDuplicate = GameObjectEx.FilterParentsOnly(rootsToDuplicate); }