EasyTouchInspector.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. using HedgehogTeam.EasyTouch;
  5. #if UNITY_5_3
  6. using UnityEditor.SceneManagement;
  7. #endif
  8. [CustomEditor(typeof(EasyTouch))]
  9. public class EasyTouchInspector : Editor {
  10. public override void OnInspectorGUI(){
  11. EasyTouch t = (EasyTouch)target;
  12. #region General properties
  13. EditorGUILayout.Space();
  14. t.enable = HTGuiTools.Toggle("Enable EasyTouch", t.enable,true);
  15. t.enableRemote = HTGuiTools.Toggle("Enable Unity Remote", t.enableRemote,true);
  16. EditorGUILayout.Space();
  17. #endregion
  18. #region Gui propertie
  19. t.showGuiInspector = HTGuiTools.BeginFoldOut( "GUI compatibilty",t.showGuiInspector);
  20. if (t.showGuiInspector){
  21. HTGuiTools.BeginGroup();{
  22. // UGUI
  23. EditorGUILayout.Space();
  24. t.allowUIDetection = HTGuiTools.Toggle("Enable Unity UI detection",t.allowUIDetection,true);
  25. if (t.allowUIDetection ){
  26. EditorGUI.indentLevel++;
  27. t.enableUIMode = HTGuiTools.Toggle("Unity UI compatibilty", t.enableUIMode,true);
  28. t.autoUpdatePickedUI = HTGuiTools.Toggle("Auto update picked Unity UI", t.autoUpdatePickedUI,true);
  29. EditorGUI.indentLevel--;
  30. }
  31. EditorGUILayout.Space();
  32. // NGUI
  33. t.enabledNGuiMode = HTGuiTools.Toggle("Enable NGUI compatibilty", t.enabledNGuiMode,true);
  34. if (t.enabledNGuiMode){
  35. //EditorGUI.indentLevel++;
  36. HTGuiTools.BeginGroup(5);
  37. {
  38. // layers
  39. serializedObject.Update();
  40. SerializedProperty layers = serializedObject.FindProperty("nGUILayers");
  41. EditorGUILayout.PropertyField( layers,false);
  42. serializedObject.ApplyModifiedProperties();
  43. // Camera
  44. if (HTGuiTools.Button("Add camera",Color.green,100, false)){
  45. t.nGUICameras.Add( null);
  46. }
  47. for (int i=0;i< t.nGUICameras.Count;i++){
  48. EditorGUILayout.BeginHorizontal();
  49. if (HTGuiTools.Button("X",Color.red,19)){
  50. t.nGUICameras.RemoveAt(i);
  51. i--;
  52. }
  53. else{
  54. t.nGUICameras[i] = (Camera)EditorGUILayout.ObjectField("",t.nGUICameras[i],typeof(Camera),true);
  55. EditorGUILayout.EndHorizontal();
  56. }
  57. }
  58. }HTGuiTools.EndGroup();
  59. //EditorGUI.indentLevel--;
  60. }
  61. }HTGuiTools.EndGroup();
  62. }
  63. #endregion
  64. #region Auto selection properties
  65. t.showSelectInspector = HTGuiTools.BeginFoldOut( "Automatic selection",t.showSelectInspector);
  66. if (t.showSelectInspector){
  67. HTGuiTools.BeginGroup();{
  68. t.autoSelect = HTGuiTools.Toggle("Enable auto-select",t.autoSelect,true);
  69. if (t.autoSelect){
  70. EditorGUILayout.Space();
  71. // 3d layer
  72. serializedObject.Update();
  73. SerializedProperty layers = serializedObject.FindProperty("pickableLayers3D");
  74. EditorGUILayout.PropertyField( layers,true);
  75. serializedObject.ApplyModifiedProperties();
  76. t.autoUpdatePickedObject = HTGuiTools.Toggle( "Auto update picked gameobject",t.autoUpdatePickedObject,true);
  77. EditorGUILayout.Space();
  78. //2D
  79. t.enable2D = HTGuiTools.Toggle("Enable 2D collider",t.enable2D,true);
  80. if (t.enable2D){
  81. serializedObject.Update();
  82. layers = serializedObject.FindProperty("pickableLayers2D");
  83. EditorGUILayout.PropertyField( layers,true);
  84. serializedObject.ApplyModifiedProperties();
  85. }
  86. // Camera
  87. GUILayout.Space(5f);
  88. HTGuiTools.BeginGroup(5);
  89. {
  90. if (HTGuiTools.Button( "Add Camera",Color.green,100)){
  91. t.touchCameras.Add(new ECamera(null,false));
  92. }
  93. for (int i=0;i< t.touchCameras.Count;i++){
  94. EditorGUILayout.BeginHorizontal();
  95. if (HTGuiTools.Button("X",Color.red,19)){
  96. t.touchCameras.RemoveAt(i);
  97. i--;
  98. }
  99. if (i>=0){
  100. t.touchCameras[i].camera = (Camera)EditorGUILayout.ObjectField("",t.touchCameras[i].camera,typeof(Camera),true,GUILayout.MinWidth(150));
  101. t.touchCameras[i].guiCamera = EditorGUILayout.ToggleLeft("Gui",t.touchCameras[i].guiCamera,GUILayout.Width(50));
  102. EditorGUILayout.EndHorizontal();
  103. }
  104. }
  105. }HTGuiTools.EndGroup();
  106. }
  107. }HTGuiTools.EndGroup();
  108. }
  109. #endregion
  110. #region General gesture properties
  111. t.showGestureInspector = HTGuiTools.BeginFoldOut("General gesture properties",t.showGestureInspector);
  112. if (t.showGestureInspector){
  113. HTGuiTools.BeginGroup();{
  114. t.gesturePriority =(EasyTouch.GesturePriority) EditorGUILayout.EnumPopup("Priority to",t.gesturePriority );
  115. t.StationaryTolerance = EditorGUILayout.FloatField("Stationary tolerance",t.StationaryTolerance);
  116. t.longTapTime = EditorGUILayout.FloatField("Long tap time",t.longTapTime);
  117. EditorGUILayout.Space ();
  118. t.doubleTapDetection = (EasyTouch.DoubleTapDetection) EditorGUILayout.EnumPopup("Double tap detection",t.doubleTapDetection);
  119. if (t.doubleTapDetection == EasyTouch.DoubleTapDetection.ByTime){
  120. t.doubleTapTime = EditorGUILayout.Slider("Double tap time",t.doubleTapTime,0.15f,0.4f);
  121. }
  122. EditorGUILayout.Space ();
  123. t.swipeTolerance = EditorGUILayout.FloatField("Swipe tolerance",t.swipeTolerance);
  124. t.alwaysSendSwipe = EditorGUILayout.Toggle("always sent swipe event",t.alwaysSendSwipe);
  125. }HTGuiTools.EndGroup();
  126. }
  127. #endregion
  128. #region 2 fingers gesture
  129. t.showTwoFingerInspector = HTGuiTools.BeginFoldOut("Two fingers gesture properties",t.showTwoFingerInspector);
  130. if (t.showTwoFingerInspector){
  131. HTGuiTools.BeginGroup();{
  132. t.enable2FingersGesture = HTGuiTools.Toggle("2 fingers gesture",t.enable2FingersGesture,true);
  133. if (t.enable2FingersGesture){
  134. EditorGUI.indentLevel++;
  135. t.twoFingerPickMethod = (EasyTouch.TwoFingerPickMethod)EditorGUILayout.EnumPopup("Pick method",t.twoFingerPickMethod);
  136. EditorGUILayout.Separator();
  137. t.enable2FingersSwipe = HTGuiTools.Toggle("Enable swipe & drag",t.enable2FingersSwipe,true);
  138. EditorGUILayout.Separator();
  139. t.enablePinch = HTGuiTools.Toggle("Enable Pinch",t.enablePinch,true);
  140. if (t.enablePinch){
  141. t.minPinchLength = EditorGUILayout.FloatField("Min pinch length",t.minPinchLength);
  142. }
  143. EditorGUILayout.Separator();
  144. t.enableTwist = HTGuiTools.Toggle("Enable twist",t.enableTwist,true);
  145. if (t.enableTwist){
  146. t.minTwistAngle = EditorGUILayout.FloatField("Min twist angle",t.minTwistAngle);
  147. }
  148. EditorGUI.indentLevel--;
  149. }
  150. }HTGuiTools.EndGroup();
  151. }
  152. #endregion
  153. #region Second Finger simulation
  154. t.showSecondFingerInspector = HTGuiTools.BeginFoldOut("Second finger simulation", t.showSecondFingerInspector);
  155. if (t.showSecondFingerInspector){
  156. HTGuiTools.BeginGroup();{
  157. t.enableSimulation = HTGuiTools.Toggle("Enable simulation",t.enableSimulation,true );
  158. EditorGUILayout.Space();
  159. if (t.enableSimulation){
  160. EditorGUI.indentLevel++;
  161. if (t.secondFingerTexture==null){
  162. t.secondFingerTexture =Resources.Load("secondFinger") as Texture;
  163. }
  164. t.secondFingerTexture = (Texture)EditorGUILayout.ObjectField("Texture",t.secondFingerTexture,typeof(Texture),true);
  165. EditorGUILayout.HelpBox("Change the keys settings for a fash compilation, or if you want to change the keys",MessageType.Info);
  166. t.twistKey = (KeyCode)EditorGUILayout.EnumPopup( "Twist & pinch key", t.twistKey);
  167. t.swipeKey = (KeyCode)EditorGUILayout.EnumPopup( "Swipe key", t.swipeKey);
  168. EditorGUI.indentLevel--;
  169. }
  170. }HTGuiTools.EndGroup();
  171. }
  172. #endregion
  173. if (GUI.changed){
  174. EditorUtility.SetDirty(target);
  175. #if UNITY_5_3
  176. EditorSceneManager.MarkSceneDirty( EditorSceneManager.GetActiveScene());
  177. #endif
  178. }
  179. }
  180. }