DEMO_UOC_GUI.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. using System;
  2. using UnityEngine;
  3. public class DEMO_UOC_GUI : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. }
  8. private void Update()
  9. {
  10. if (this.target.invertAxisX)
  11. {
  12. this.target.invertXValue = -1;
  13. }
  14. else
  15. {
  16. this.target.invertXValue = 1;
  17. }
  18. if (this.target.invertAxisY)
  19. {
  20. this.target.invertYValue = -1;
  21. }
  22. else
  23. {
  24. this.target.invertYValue = 1;
  25. }
  26. if (this.target.invertAxisZoom)
  27. {
  28. this.target.invertZoomValue = -1;
  29. }
  30. else
  31. {
  32. this.target.invertZoomValue = 1;
  33. }
  34. if (this.target.autoRotateReverse)
  35. {
  36. this.target.autoRotateReverseValue = -1;
  37. }
  38. else
  39. {
  40. this.target.autoRotateReverseValue = 1;
  41. }
  42. }
  43. private void OnGUI()
  44. {
  45. this.height = 204;
  46. if (this.showOrbitOptions)
  47. {
  48. this.height += 570;
  49. }
  50. if (this.showMouseOptions)
  51. {
  52. this.height += 130;
  53. }
  54. if (this.showKeyboardOptions)
  55. {
  56. this.height += 40;
  57. }
  58. if (this.showAutoRotateOptions)
  59. {
  60. this.height += 80;
  61. }
  62. if (this.showSpinOptions)
  63. {
  64. this.height += 100;
  65. }
  66. if (this.showCollisionOptions)
  67. {
  68. this.height += 80;
  69. }
  70. if (GUI.Button(new Rect((float)(Screen.width - 105), 5f, 100f, 50f), "Reset"))
  71. {
  72. Application.LoadLevel(Application.loadedLevel);
  73. }
  74. GUI.Box(new Rect(10f, 10f, 340f, (float)Mathf.Min(this.height, Screen.height - 20)), string.Empty);
  75. GUILayout.BeginArea(new Rect(12f, 12f, 336f, (float)Mathf.Min(this.height - 4, Screen.height - 24)));
  76. this.scrollPos = GUILayout.BeginScrollView(this.scrollPos, new GUILayoutOption[0]);
  77. this.showOrbitOptions = GUILayout.Toggle(this.showOrbitOptions, " Show Orbit Options", new GUILayoutOption[0]);
  78. GUILayout.Space(4f);
  79. if (this.showOrbitOptions)
  80. {
  81. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  82. GUILayout.Label("Axis X Speed", new GUILayoutOption[]
  83. {
  84. GUILayout.Width((float)this.LabelWidth)
  85. });
  86. this.target.xSpeed = GUILayout.HorizontalSlider(this.target.xSpeed, 0f, 2f, new GUILayoutOption[]
  87. {
  88. GUILayout.Width((float)this.SliderWidth)
  89. });
  90. GUILayout.Label(this.target.xSpeed.ToString("F"), new GUILayoutOption[0]);
  91. GUILayout.EndHorizontal();
  92. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  93. GUILayout.Label("Axis Y Speed", new GUILayoutOption[]
  94. {
  95. GUILayout.Width((float)this.LabelWidth)
  96. });
  97. this.target.ySpeed = GUILayout.HorizontalSlider(this.target.ySpeed, 0f, 2f, new GUILayoutOption[]
  98. {
  99. GUILayout.Width((float)this.SliderWidth)
  100. });
  101. GUILayout.Label(this.target.ySpeed.ToString("F"), new GUILayoutOption[0]);
  102. GUILayout.EndHorizontal();
  103. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  104. GUILayout.Label("Zoom Sensitivity", new GUILayoutOption[]
  105. {
  106. GUILayout.Width((float)this.LabelWidth)
  107. });
  108. this.target.zoomSpeed = GUILayout.HorizontalSlider(this.target.zoomSpeed, 0f, 50f, new GUILayoutOption[]
  109. {
  110. GUILayout.Width((float)this.SliderWidth)
  111. });
  112. GUILayout.Label(this.target.zoomSpeed.ToString("F"), new GUILayoutOption[0]);
  113. GUILayout.EndHorizontal();
  114. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  115. GUILayout.Label("Axis X Dampening", new GUILayoutOption[]
  116. {
  117. GUILayout.Width((float)this.LabelWidth)
  118. });
  119. this.target.dampeningX = GUILayout.HorizontalSlider(this.target.dampeningX, 0.01f, 0.99f, new GUILayoutOption[]
  120. {
  121. GUILayout.Width((float)this.SliderWidth)
  122. });
  123. GUILayout.Label(this.target.dampeningX.ToString("F"), new GUILayoutOption[0]);
  124. GUILayout.EndHorizontal();
  125. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  126. GUILayout.Label("Axis Y Dampening", new GUILayoutOption[]
  127. {
  128. GUILayout.Width((float)this.LabelWidth)
  129. });
  130. this.target.dampeningY = GUILayout.HorizontalSlider(this.target.dampeningY, 0.01f, 0.99f, new GUILayoutOption[]
  131. {
  132. GUILayout.Width((float)this.SliderWidth)
  133. });
  134. GUILayout.Label(this.target.dampeningY.ToString("F"), new GUILayoutOption[0]);
  135. GUILayout.EndHorizontal();
  136. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  137. GUILayout.Label("Zoom Smoothing", new GUILayoutOption[]
  138. {
  139. GUILayout.Width((float)this.LabelWidth)
  140. });
  141. this.target.smoothingZoom = GUILayout.HorizontalSlider(this.target.smoothingZoom, 0.01f, 1f, new GUILayoutOption[]
  142. {
  143. GUILayout.Width((float)this.SliderWidth)
  144. });
  145. GUILayout.Label(this.target.smoothingZoom.ToString("F"), new GUILayoutOption[0]);
  146. GUILayout.EndHorizontal();
  147. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  148. GUILayout.Label("Min Distance", new GUILayoutOption[]
  149. {
  150. GUILayout.Width((float)this.LabelWidth)
  151. });
  152. this.target.minDistance = Mathf.Min(this.target.maxDistance, GUILayout.HorizontalSlider(this.target.minDistance, 1f, 50f, new GUILayoutOption[]
  153. {
  154. GUILayout.Width((float)this.SliderWidth)
  155. }));
  156. GUILayout.Label(this.target.minDistance.ToString("F"), new GUILayoutOption[0]);
  157. GUILayout.EndHorizontal();
  158. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  159. GUILayout.Label("MaxDistance", new GUILayoutOption[]
  160. {
  161. GUILayout.Width((float)this.LabelWidth)
  162. });
  163. this.target.maxDistance = Mathf.Max(this.target.minDistance, GUILayout.HorizontalSlider(this.target.maxDistance, 1f, 50f, new GUILayoutOption[]
  164. {
  165. GUILayout.Width((float)this.SliderWidth)
  166. }));
  167. GUILayout.Label(this.target.maxDistance.ToString("F"), new GUILayoutOption[0]);
  168. GUILayout.EndHorizontal();
  169. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  170. GUILayout.Label("Limit Angle X", new GUILayoutOption[]
  171. {
  172. GUILayout.Width((float)this.LabelWidth)
  173. });
  174. this.target.limitX = GUILayout.Toggle(this.target.limitX, string.Empty, new GUILayoutOption[0]);
  175. GUILayout.EndHorizontal();
  176. if (!this.target.limitX)
  177. {
  178. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  179. }
  180. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  181. GUILayout.Label("Min Angle X", new GUILayoutOption[]
  182. {
  183. GUILayout.Width((float)this.LabelWidth)
  184. });
  185. this.target.xMinLimit = Mathf.Min(this.target.xMaxLimit, GUILayout.HorizontalSlider(this.target.xMinLimit, -180f, 180f, new GUILayoutOption[]
  186. {
  187. GUILayout.Width((float)this.SliderWidth)
  188. }));
  189. GUILayout.Label(this.target.xMinLimit.ToString("F"), new GUILayoutOption[0]);
  190. GUILayout.EndHorizontal();
  191. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  192. GUILayout.Label("Max Angle X", new GUILayoutOption[]
  193. {
  194. GUILayout.Width((float)this.LabelWidth)
  195. });
  196. this.target.xMaxLimit = Mathf.Max(this.target.xMinLimit, GUILayout.HorizontalSlider(this.target.xMaxLimit, -180f, 180f, new GUILayoutOption[]
  197. {
  198. GUILayout.Width((float)this.SliderWidth)
  199. }));
  200. GUILayout.Label(this.target.xMaxLimit.ToString("F"), new GUILayoutOption[0]);
  201. GUILayout.EndHorizontal();
  202. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  203. GUILayout.Label("X Limit Offset", new GUILayoutOption[]
  204. {
  205. GUILayout.Width((float)this.LabelWidth)
  206. });
  207. this.target.xLimitOffset = GUILayout.HorizontalSlider(this.target.xLimitOffset, 0f, 360f, new GUILayoutOption[]
  208. {
  209. GUILayout.Width((float)this.SliderWidth)
  210. });
  211. GUILayout.Label(this.target.xLimitOffset.ToString("F"), new GUILayoutOption[0]);
  212. GUILayout.EndHorizontal();
  213. GUI.color = new Color(1f, 1f, 1f);
  214. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  215. GUILayout.Label("Limit Angle Y", new GUILayoutOption[]
  216. {
  217. GUILayout.Width((float)this.LabelWidth)
  218. });
  219. this.target.limitY = GUILayout.Toggle(this.target.limitY, string.Empty, new GUILayoutOption[0]);
  220. GUILayout.EndHorizontal();
  221. if (!this.target.limitY)
  222. {
  223. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  224. }
  225. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  226. GUILayout.Label("Min Angle Y", new GUILayoutOption[]
  227. {
  228. GUILayout.Width((float)this.LabelWidth)
  229. });
  230. this.target.yMinLimit = Mathf.Min(this.target.yMaxLimit, GUILayout.HorizontalSlider(this.target.yMinLimit, -180f, 180f, new GUILayoutOption[]
  231. {
  232. GUILayout.Width((float)this.SliderWidth)
  233. }));
  234. GUILayout.Label(this.target.yMinLimit.ToString("F"), new GUILayoutOption[0]);
  235. GUILayout.EndHorizontal();
  236. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  237. GUILayout.Label("Max Angle Y", new GUILayoutOption[]
  238. {
  239. GUILayout.Width((float)this.LabelWidth)
  240. });
  241. this.target.yMaxLimit = Mathf.Max(this.target.yMinLimit, GUILayout.HorizontalSlider(this.target.yMaxLimit, -180f, 180f, new GUILayoutOption[]
  242. {
  243. GUILayout.Width((float)this.SliderWidth)
  244. }));
  245. GUILayout.Label(this.target.yMaxLimit.ToString("F"), new GUILayoutOption[0]);
  246. GUILayout.EndHorizontal();
  247. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  248. GUILayout.Label("Y Limit Offset", new GUILayoutOption[]
  249. {
  250. GUILayout.Width((float)this.LabelWidth)
  251. });
  252. this.target.yLimitOffset = GUILayout.HorizontalSlider(this.target.yLimitOffset, 0f, 360f, new GUILayoutOption[]
  253. {
  254. GUILayout.Width((float)this.SliderWidth)
  255. });
  256. GUILayout.Label(this.target.yLimitOffset.ToString("F"), new GUILayoutOption[0]);
  257. GUILayout.EndHorizontal();
  258. GUI.color = new Color(1f, 1f, 1f);
  259. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  260. GUILayout.Label("Invert Axis X", new GUILayoutOption[]
  261. {
  262. GUILayout.Width((float)this.LabelWidth)
  263. });
  264. this.target.invertAxisX = GUILayout.Toggle(this.target.invertAxisX, string.Empty, new GUILayoutOption[0]);
  265. GUILayout.EndHorizontal();
  266. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  267. GUILayout.Label("Invert Axis Y", new GUILayoutOption[]
  268. {
  269. GUILayout.Width((float)this.LabelWidth)
  270. });
  271. this.target.invertAxisY = GUILayout.Toggle(this.target.invertAxisY, string.Empty, new GUILayoutOption[0]);
  272. GUILayout.EndHorizontal();
  273. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  274. GUILayout.Label("Invert Zoom", new GUILayoutOption[]
  275. {
  276. GUILayout.Width((float)this.LabelWidth)
  277. });
  278. this.target.invertAxisZoom = GUILayout.Toggle(this.target.invertAxisZoom, string.Empty, new GUILayoutOption[0]);
  279. GUILayout.EndHorizontal();
  280. }
  281. GUILayout.Space(8f);
  282. this.showMouseOptions = GUILayout.Toggle(this.showMouseOptions, " Show Mouse Input Options", new GUILayoutOption[0]);
  283. GUILayout.Space(4f);
  284. if (this.showMouseOptions)
  285. {
  286. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  287. GUILayout.Label("Mouse Controls", new GUILayoutOption[]
  288. {
  289. GUILayout.Width((float)this.LabelWidth)
  290. });
  291. this.target.mouseControl = GUILayout.Toggle(this.target.mouseControl, string.Empty, new GUILayoutOption[0]);
  292. GUILayout.EndHorizontal();
  293. if (!this.target.mouseControl)
  294. {
  295. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  296. }
  297. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  298. GUILayout.Label("Click To Rotate", new GUILayoutOption[]
  299. {
  300. GUILayout.Width((float)this.LabelWidth)
  301. });
  302. this.target.clickToRotate = GUILayout.Toggle(this.target.clickToRotate, string.Empty, new GUILayoutOption[0]);
  303. GUILayout.EndHorizontal();
  304. if (!this.target.clickToRotate)
  305. {
  306. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  307. }
  308. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  309. GUILayout.Label("Left Click", new GUILayoutOption[]
  310. {
  311. GUILayout.Width((float)this.LabelWidth)
  312. });
  313. this.target.leftClickToRotate = GUILayout.Toggle(this.target.leftClickToRotate, string.Empty, new GUILayoutOption[0]);
  314. GUILayout.EndHorizontal();
  315. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  316. GUILayout.Label("Right Click", new GUILayoutOption[]
  317. {
  318. GUILayout.Width((float)this.LabelWidth)
  319. });
  320. this.target.rightClickToRotate = GUILayout.Toggle(this.target.rightClickToRotate, string.Empty, new GUILayoutOption[0]);
  321. GUILayout.EndHorizontal();
  322. GUI.color = new Color(1f, 1f, 1f);
  323. }
  324. GUILayout.Space(8f);
  325. this.showKeyboardOptions = GUILayout.Toggle(this.showKeyboardOptions, " Show Keyboard Input Options", new GUILayoutOption[0]);
  326. GUILayout.Space(4f);
  327. if (this.showKeyboardOptions)
  328. {
  329. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  330. GUILayout.Label("Keyboard Controls", new GUILayoutOption[]
  331. {
  332. GUILayout.Width((float)this.LabelWidth)
  333. });
  334. this.target.keyboardControl = GUILayout.Toggle(this.target.keyboardControl, string.Empty, new GUILayoutOption[0]);
  335. GUILayout.EndHorizontal();
  336. }
  337. GUILayout.Space(8f);
  338. this.showAutoRotateOptions = GUILayout.Toggle(this.showAutoRotateOptions, " Show Auto-Rotate Options", new GUILayoutOption[0]);
  339. GUILayout.Space(4f);
  340. if (this.showAutoRotateOptions)
  341. {
  342. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  343. GUILayout.Label("Auto Rotate", new GUILayoutOption[]
  344. {
  345. GUILayout.Width((float)this.LabelWidth)
  346. });
  347. this.target.autoRotateOn = GUILayout.Toggle(this.target.autoRotateOn, string.Empty, new GUILayoutOption[0]);
  348. GUILayout.EndHorizontal();
  349. if (!this.target.autoRotateOn)
  350. {
  351. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  352. }
  353. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  354. GUILayout.Label("Reverse", new GUILayoutOption[]
  355. {
  356. GUILayout.Width((float)this.LabelWidth)
  357. });
  358. this.target.autoRotateReverse = GUILayout.Toggle(this.target.autoRotateReverse, string.Empty, new GUILayoutOption[0]);
  359. GUILayout.EndHorizontal();
  360. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  361. GUILayout.Label("Rotate Speed", new GUILayoutOption[]
  362. {
  363. GUILayout.Width((float)this.LabelWidth)
  364. });
  365. this.target.autoRotateSpeed = GUILayout.HorizontalSlider(this.target.autoRotateSpeed, 0.01f, 20f, new GUILayoutOption[]
  366. {
  367. GUILayout.Width((float)this.SliderWidth)
  368. });
  369. GUILayout.Label(this.target.autoRotateSpeed.ToString("F"), new GUILayoutOption[0]);
  370. GUILayout.EndHorizontal();
  371. GUI.color = new Color(1f, 1f, 1f);
  372. }
  373. GUILayout.Space(8f);
  374. this.showSpinOptions = GUILayout.Toggle(this.showSpinOptions, " Show Spin Options", new GUILayoutOption[0]);
  375. GUILayout.Space(4f);
  376. if (this.showSpinOptions)
  377. {
  378. GUILayout.Label("Hold Left-CTRL and throw to spin.", new GUILayoutOption[0]);
  379. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  380. GUILayout.Label("Spin Enabled", new GUILayoutOption[]
  381. {
  382. GUILayout.Width((float)this.LabelWidth)
  383. });
  384. this.target.SpinEnabled = GUILayout.Toggle(this.target.SpinEnabled, string.Empty, new GUILayoutOption[0]);
  385. GUILayout.EndHorizontal();
  386. if (!this.target.SpinEnabled)
  387. {
  388. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  389. }
  390. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  391. GUILayout.Label("Max Spin Speed", new GUILayoutOption[]
  392. {
  393. GUILayout.Width((float)this.LabelWidth)
  394. });
  395. this.target.maxSpinSpeed = GUILayout.HorizontalSlider(this.target.maxSpinSpeed, 0.01f, 5f, new GUILayoutOption[]
  396. {
  397. GUILayout.Width((float)this.SliderWidth)
  398. });
  399. GUILayout.Label(this.target.maxSpinSpeed.ToString("F"), new GUILayoutOption[0]);
  400. GUILayout.EndHorizontal();
  401. GUI.color = new Color(1f, 1f, 1f);
  402. }
  403. GUILayout.Space(8f);
  404. this.showCollisionOptions = GUILayout.Toggle(this.showCollisionOptions, " Show Collision Options", new GUILayoutOption[0]);
  405. GUILayout.Space(4f);
  406. if (this.showCollisionOptions)
  407. {
  408. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  409. GUILayout.Label("Collision Enabled", new GUILayoutOption[]
  410. {
  411. GUILayout.Width((float)this.LabelWidth)
  412. });
  413. this.target.cameraCollision = GUILayout.Toggle(this.target.cameraCollision, string.Empty, new GUILayoutOption[0]);
  414. GUILayout.EndHorizontal();
  415. if (!this.target.cameraCollision)
  416. {
  417. GUI.color = new Color(0.5f, 0.5f, 0.5f);
  418. }
  419. GUILayout.BeginHorizontal(new GUILayoutOption[0]);
  420. GUILayout.Label("Collision Radius", new GUILayoutOption[]
  421. {
  422. GUILayout.Width((float)this.LabelWidth)
  423. });
  424. this.target.collisionRadius = GUILayout.HorizontalSlider(this.target.collisionRadius, 0.01f, 1f, new GUILayoutOption[]
  425. {
  426. GUILayout.Width((float)this.SliderWidth)
  427. });
  428. GUILayout.Label(this.target.collisionRadius.ToString("F"), new GUILayoutOption[0]);
  429. GUILayout.EndHorizontal();
  430. GUI.color = new Color(1f, 1f, 1f);
  431. }
  432. GUILayout.EndScrollView();
  433. GUILayout.EndArea();
  434. }
  435. public UltimateOrbitCamera target;
  436. private int height;
  437. private bool showOrbitOptions;
  438. private bool showMouseOptions;
  439. private bool showKeyboardOptions;
  440. private bool showAutoRotateOptions;
  441. private bool showSpinOptions;
  442. private bool showCollisionOptions;
  443. private int LabelWidth = 80;
  444. private int SliderWidth = 180;
  445. private Vector2 scrollPos = new Vector2(0f, 0f);
  446. }