public void Snap() { float offsetFromSurface = SourcePrefab.OffsetFromGridSurface; if (ObjectSnapping.Get().SnapSurfaceType != SnapSurfaceType.GridCell) { offsetFromSurface = SourcePrefab.OffsetFromObjectSurface; } if (AllShortcutCombos.Instance.PlaceGuideBehindSurfacePlane.IsActive()) { offsetFromSurface *= -1.0f; } if (AllShortcutCombos.Instance.SnapCenterToCenter.IsActive()) { ObjectSnapping.Get().SnapObjectHierarchyToCenterOfSnapSurface(gameObject, ObjectPlacement.Get().CenterProjectedGuidePivotPoint, ObjectPlacement.Get().ProjectedGuidePivotPoints, offsetFromSurface); } else { ObjectSnapping.Get().SnapObjectHierarchy(gameObject, ObjectPlacement.Get().ProjectedGuidePivotPoints, offsetFromSurface); } PersistentObjectPlacementGuideData.Get().LastUsedWorldPosition = _transform.position; }
private void Start() { // Note: We will always ensure that the guide is placed in the last position which it had before // it was destroyed. Although not strictly necessary, it is more pleasent than to see it // suddenly snap to position <0, 0, 0> every time an Undo/Redo operation is performed or // when the scripts are recompiled. // Note: This has to be done from the 'Start' function because here we can be sure that the object // which holds the persistent guide data has been created. gameObject.transform.position = PersistentObjectPlacementGuideData.Get().LastUsedWorldPosition; }
public void RegisterCurrentPosition() { PersistentObjectPlacementGuideData.Get().LastUsedWorldPosition = _transform.position; }
public void SetWorldPosition(Vector3 position) { _transform.position = position; PersistentObjectPlacementGuideData.Get().LastUsedWorldPosition = _transform.position; }