29 return _pinchDetectorA;
32 _pinchDetectorA = value;
40 return _pinchDetectorB;
43 _pinchDetectorB = value;
54 private bool _allowScale =
true;
56 [Header(
"GUI Options")]
58 private KeyCode _toggleGuiState = KeyCode.None;
61 private bool _showGUI =
true;
63 private Transform _anchor;
65 private float _defaultNearClip;
73 GameObject pinchControl =
new GameObject(
"RTS Anchor");
74 _anchor = pinchControl.transform;
75 _anchor.transform.parent = transform.parent;
76 transform.parent = _anchor;
80 if (Input.GetKeyDown(_toggleGuiState)) {
84 bool didUpdate =
false;
85 if(_pinchDetectorA !=
null)
87 if(_pinchDetectorB !=
null)
91 transform.SetParent(
null,
true);
94 if (_pinchDetectorA !=
null && _pinchDetectorA.
IsActive &&
95 _pinchDetectorB !=
null &&_pinchDetectorB.
IsActive) {
96 transformDoubleAnchor();
97 }
else if (_pinchDetectorA !=
null && _pinchDetectorA.
IsActive) {
98 transformSingleAnchor(_pinchDetectorA);
99 }
else if (_pinchDetectorB !=
null && _pinchDetectorB.
IsActive) {
100 transformSingleAnchor(_pinchDetectorB);
104 transform.SetParent(_anchor,
true);
110 GUILayout.Label(
"One Handed Settings");
111 doRotationMethodGUI(ref _oneHandedRotationMethod);
112 GUILayout.Label(
"Two Handed Settings");
113 doRotationMethodGUI(ref _twoHandedRotationMethod);
114 _allowScale = GUILayout.Toggle(_allowScale,
"Allow Two Handed Scale");
118 private void doRotationMethodGUI(ref
RotationMethod rotationMethod) {
119 GUILayout.BeginHorizontal();
122 if (GUILayout.Button(
"No Rotation")) {
127 if (GUILayout.Button(
"Single Axis")) {
132 if (GUILayout.Button(
"Full Rotation")) {
136 GUI.color =
Color.white;
138 GUILayout.EndHorizontal();
141 private void transformDoubleAnchor() {
142 _anchor.position = (_pinchDetectorA.
Position + _pinchDetectorB.
Position) / 2.0f;
144 switch (_twoHandedRotationMethod) {
149 p.y = _anchor.position.y;
155 _anchor.LookAt(_pinchDetectorA.
Position, u);
164 private void transformSingleAnchor(PinchDetector singlePinch) {
165 _anchor.position = singlePinch.Position;
167 switch (_oneHandedRotationMethod) {
172 p.y = _anchor.position.y;
176 _anchor.rotation = singlePinch.Rotation;
180 _anchor.localScale =
Vector3.one;
Vector3 Position
Returns the position value of the detected pinch or grab. If a pinch or grab is not currently being d...
virtual bool DidChangeFromLastFrame
Returns whether or not the value of IsPinching is different than the value reported during the previo...
Quaternion Rotation
Returns the rotation value of the detected pinch or grab. If a pinch or grab is not currently being d...
Use this component on a Game Object to allow it to be manipulated by a pinch gesture....
PinchDetector PinchDetectorA
PinchDetector PinchDetectorB
A basic utility class to aid in creating pinch based actions. Once linked with a HandModelBase,...