public bool StartPlaySpaceCentrePivot(Transform controller, TweakActionArea area) { if (TweakAction != TweakActionType.none) { return(false); } TweakAction = TweakActionType.psPivot; TweakControllerInitPos = controller.position; TweakControllerTrans = controller; TweakPivotPoint = PlaySpace.transform.position; if (area == TweakActionArea.bottomLeft) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(-0.5f, 0, -0.5f)); } else if (area == TweakActionArea.bottomRight) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(0.5f, 0, -0.5f)); } else if (area == TweakActionArea.topLeft) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(-0.5f, 0, 0.5f)); } else if (area == TweakActionArea.topRight) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(0.5f, 0, 0.5f)); } TweakYawDelta = PlaySpace.transform.localEulerAngles.y - Quaternion.LookRotation(TweakTargetInitPoint - TweakPivotPoint, Vector3.up).eulerAngles.y; return(true); }
public bool StartPlaySpaceEdgeResize(Transform controller, TweakActionArea area) { if (TweakAction != TweakActionType.none) { return(false); } TweakAction = TweakActionType.psEdgeResize; TweakControllerInitPos = controller.position; TweakControllerTrans = controller; if ((area == TweakActionArea.bottom) || (area == TweakActionArea.top)) { TweakInitScaleF = PlaySpace.transform.localScale.z; } else { TweakInitScaleF = PlaySpace.transform.localScale.x; } TweakArea = area; TweakTargetInitPoint = PlaySpace.transform.position; return(true); }
public bool SetFront(TweakActionArea area) { if (TweakAction != TweakActionType.none) { return(false); } TweakAction = TweakActionType.psSetFront; if (area == TweakActionArea.left) { PlaySpace.transform.localScale = new Vector3(PlaySpace.transform.localScale.z, PlaySpace.transform.localScale.y, PlaySpace.transform.localScale.x); PlaySpace.transform.Rotate(0, -90, 0); } else if (area == TweakActionArea.right) { PlaySpace.transform.localScale = new Vector3(PlaySpace.transform.localScale.z, PlaySpace.transform.localScale.y, PlaySpace.transform.localScale.x); PlaySpace.transform.Rotate(0, 90, 0); } else if (area == TweakActionArea.bottom) { PlaySpace.transform.Rotate(0, 180, 0); } return(true); }
public bool StartPlaySpaceCornerPivot(Transform controller, TweakActionArea area) { if (TweakAction != TweakActionType.none) { return(false); } TweakAction = TweakActionType.psPivotScale; TweakControllerInitPos = controller.position; TweakControllerTrans = controller; if (area == TweakActionArea.bottomLeft) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(-0.5f, 0, -0.5f)); TweakPivotPoint = PlaySpace.transform.TransformPoint(new Vector3(0.5f, 0, 0.5f)); } else if (area == TweakActionArea.bottomRight) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(0.5f, 0, -0.5f)); TweakPivotPoint = PlaySpace.transform.TransformPoint(new Vector3(-0.5f, 0, 0.5f)); } else if (area == TweakActionArea.topLeft) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(-0.5f, 0, 0.5f)); TweakPivotPoint = PlaySpace.transform.TransformPoint(new Vector3(0.5f, 0, -0.5f)); } else if (area == TweakActionArea.topRight) { TweakTargetInitPoint = PlaySpace.transform.TransformPoint(new Vector3(0.5f, 0, 0.5f)); TweakPivotPoint = PlaySpace.transform.TransformPoint(new Vector3(-0.5f, 0, -0.5f)); } TweakMinScale = Mathf.Sqrt(Mathf.Pow(MinimumScale / Mathf.Min(PlaySpace.transform.localScale.x, PlaySpace.transform.localScale.z) * PlaySpace.transform.localScale.x, 2) + Mathf.Pow(MinimumScale / Mathf.Min(PlaySpace.transform.localScale.x, PlaySpace.transform.localScale.z) * PlaySpace.transform.localScale.z, 2)); TweakInitScaleV = PlaySpace.transform.localScale; TweakYawDelta = PlaySpace.transform.localEulerAngles.y - Quaternion.LookRotation(TweakTargetInitPoint - TweakPivotPoint, Vector3.up).eulerAngles.y; return(true); }