2using System.Collections.Generic;
16 private bool global =
true;
19 private Transform _mTransform;
22 private Transform mTransform
26 if (_mTransform ==
null)
28 _mTransform =
new GameObject().transform;
29 _mTransform.name =
"Handle Transform Parent";
46 dragRectStyle.normal.background = pb_BuiltinResource.GetResource<Texture2D>(pb_BuiltinResource.img_WhiteTexture);
54 handleTransformOrigin = transform;
55 CacheSelectionTransforms();
63 pb_Transform delta = (transform - handleTransformOrigin);
67 mTransform.SetTRS(handleTransformOrigin);
74 go.transform.SetTRS(selectionTransformOrigin[i]);
75 parents[i] = go.transform.parent;
76 go.transform.parent = mTransform;
79 mTransform.SetTRS(transform);
91 go.transform.SetTRS( selectionTransformOrigin[i] + delta );
99 void CacheSelectionTransforms()
103 for(
int i = 0; i < count; i++)
113 private bool mMouseDragging =
false,
114 mMouseIsDown =
false,
115 mDragCanceled =
false;
116 const float MOUSE_DRAG_DELTA = .2f;
117 private Rect dragRect =
new Rect(0,0,0,0);
118 private GUIStyle dragRectStyle =
new GUIStyle();
128 GUI.Box(dragRect,
"", dragRectStyle);
129 GUI.color =
Color.white;
142 mDragCanceled =
true;
143 mMouseDragging =
false;
147 dragRect.x = Mathf.Min(mMouseOrigin.x, Input.mousePosition.x);
148 dragRect.y = Screen.height - Mathf.Max(mMouseOrigin.y, Input.mousePosition.y);
149 dragRect.width = Mathf.Abs(mMouseOrigin.x - Input.mousePosition.x);
150 dragRect.height = Mathf.Abs(mMouseOrigin.y - Input.mousePosition.y);
155 if(mMouseIsDown && !mDragCanceled && Vector2.Distance(mMouseOrigin, Input.mousePosition) > MOUSE_DRAG_DELTA)
160 mMouseDragging =
true;
162 dragRect.x = mMouseOrigin.x;
163 dragRect.y = Screen.height - mMouseOrigin.y;
165 dragRect.height = 0f;
173 mMouseOrigin = Input.mousePosition;
174 mDragCanceled =
false;
181 if( !handle.
InUse() )
183 if(mMouseDragging || mDragCanceled)
185 mDragCanceled =
false;
186 mMouseDragging =
false;
190 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
212 if(!pb_InputExtension.Shift() && !pb_InputExtension.Control())
222 if(!pb_InputExtension.Shift() && !pb_InputExtension.Control())
239 if( Input.GetKey(KeyCode.LeftCommand) || Input.GetKey(KeyCode.LeftControl) )
271 handle.
SetTRS(t.position, t.localRotation, Vector3.one);
291 return base.EnableCameraControls() || Input.GetKey(KeyCode.Q);
297 void UpdateDragPicker()
299 Rect screenRect =
new Rect(dragRect.x, Screen.height - (dragRect.y + dragRect.height), dragRect.width, dragRect.height);
301 List<GameObject> selected =
new List<GameObject>();
305 Vector2 pos = Camera.main.WorldToScreenPoint(go.transform.position);
307 if(screenRect.Contains(pos))
313 pb_Selection.SetSelection(selected);
static void RegisterStates(IEnumerable< IUndo > targets, string message)
static void RegisterState(IUndo target, string message)
static GameObject ObjectRaycast(Ray ray, IEnumerable< GameObject > objects, bool ignoreSelection=false)
override void OnKeyDown()
override void OnSelectionChange(IEnumerable< GameObject > added)
override void OnHandleMove(pb_Transform transform)
override void OnMouseDown()
override void OnMouseUp()
override void OnMouseMove()
override bool EnableCameraControls()
override void OnFrameSelection()
override void OnHandleBegin(pb_Transform transform)
static void Focus(Vector3 target)
virtual bool IsMouseInUse()
static List< GameObject > Children()
void SetTRS(Vector3 position, Quaternion rotation, Vector3 scale)
void SetIsHidden(bool isHidden)
static List< GameObject > gameObjects
A list of the currently selected GameObjects.
static void AddToSelection(GameObject go)
static void SetSelection(IEnumerable< GameObject > selection)
static GameObject activeGameObject