123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- using System;
- using UnityEngine;
- public class DEMO_UOC_GUI : MonoBehaviour
- {
- private void Start()
- {
- }
- private void Update()
- {
- if (this.target.invertAxisX)
- {
- this.target.invertXValue = -1;
- }
- else
- {
- this.target.invertXValue = 1;
- }
- if (this.target.invertAxisY)
- {
- this.target.invertYValue = -1;
- }
- else
- {
- this.target.invertYValue = 1;
- }
- if (this.target.invertAxisZoom)
- {
- this.target.invertZoomValue = -1;
- }
- else
- {
- this.target.invertZoomValue = 1;
- }
- if (this.target.autoRotateReverse)
- {
- this.target.autoRotateReverseValue = -1;
- }
- else
- {
- this.target.autoRotateReverseValue = 1;
- }
- }
- private void OnGUI()
- {
- this.height = 204;
- if (this.showOrbitOptions)
- {
- this.height += 570;
- }
- if (this.showMouseOptions)
- {
- this.height += 130;
- }
- if (this.showKeyboardOptions)
- {
- this.height += 40;
- }
- if (this.showAutoRotateOptions)
- {
- this.height += 80;
- }
- if (this.showSpinOptions)
- {
- this.height += 100;
- }
- if (this.showCollisionOptions)
- {
- this.height += 80;
- }
- if (GUI.Button(new Rect((float)(Screen.width - 105), 5f, 100f, 50f), "Reset"))
- {
- Application.LoadLevel(Application.loadedLevel);
- }
- GUI.Box(new Rect(10f, 10f, 340f, (float)Mathf.Min(this.height, Screen.height - 20)), string.Empty);
- GUILayout.BeginArea(new Rect(12f, 12f, 336f, (float)Mathf.Min(this.height - 4, Screen.height - 24)));
- this.scrollPos = GUILayout.BeginScrollView(this.scrollPos, new GUILayoutOption[0]);
- this.showOrbitOptions = GUILayout.Toggle(this.showOrbitOptions, " Show Orbit Options", new GUILayoutOption[0]);
- GUILayout.Space(4f);
- if (this.showOrbitOptions)
- {
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Axis X Speed", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.xSpeed = GUILayout.HorizontalSlider(this.target.xSpeed, 0f, 2f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.xSpeed.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Axis Y Speed", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.ySpeed = GUILayout.HorizontalSlider(this.target.ySpeed, 0f, 2f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.ySpeed.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Zoom Sensitivity", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.zoomSpeed = GUILayout.HorizontalSlider(this.target.zoomSpeed, 0f, 50f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.zoomSpeed.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Axis X Dampening", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.dampeningX = GUILayout.HorizontalSlider(this.target.dampeningX, 0.01f, 0.99f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.dampeningX.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Axis Y Dampening", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.dampeningY = GUILayout.HorizontalSlider(this.target.dampeningY, 0.01f, 0.99f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.dampeningY.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Zoom Smoothing", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.smoothingZoom = GUILayout.HorizontalSlider(this.target.smoothingZoom, 0.01f, 1f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.smoothingZoom.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Min Distance", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.minDistance = Mathf.Min(this.target.maxDistance, GUILayout.HorizontalSlider(this.target.minDistance, 1f, 50f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- }));
- GUILayout.Label(this.target.minDistance.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("MaxDistance", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.maxDistance = Mathf.Max(this.target.minDistance, GUILayout.HorizontalSlider(this.target.maxDistance, 1f, 50f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- }));
- GUILayout.Label(this.target.maxDistance.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Limit Angle X", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.limitX = GUILayout.Toggle(this.target.limitX, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.limitX)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Min Angle X", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.xMinLimit = Mathf.Min(this.target.xMaxLimit, GUILayout.HorizontalSlider(this.target.xMinLimit, -180f, 180f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- }));
- GUILayout.Label(this.target.xMinLimit.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Max Angle X", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.xMaxLimit = Mathf.Max(this.target.xMinLimit, GUILayout.HorizontalSlider(this.target.xMaxLimit, -180f, 180f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- }));
- GUILayout.Label(this.target.xMaxLimit.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("X Limit Offset", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.xLimitOffset = GUILayout.HorizontalSlider(this.target.xLimitOffset, 0f, 360f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.xLimitOffset.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUI.color = new Color(1f, 1f, 1f);
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Limit Angle Y", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.limitY = GUILayout.Toggle(this.target.limitY, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.limitY)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Min Angle Y", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.yMinLimit = Mathf.Min(this.target.yMaxLimit, GUILayout.HorizontalSlider(this.target.yMinLimit, -180f, 180f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- }));
- GUILayout.Label(this.target.yMinLimit.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Max Angle Y", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.yMaxLimit = Mathf.Max(this.target.yMinLimit, GUILayout.HorizontalSlider(this.target.yMaxLimit, -180f, 180f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- }));
- GUILayout.Label(this.target.yMaxLimit.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Y Limit Offset", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.yLimitOffset = GUILayout.HorizontalSlider(this.target.yLimitOffset, 0f, 360f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.yLimitOffset.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUI.color = new Color(1f, 1f, 1f);
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Invert Axis X", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.invertAxisX = GUILayout.Toggle(this.target.invertAxisX, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Invert Axis Y", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.invertAxisY = GUILayout.Toggle(this.target.invertAxisY, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Invert Zoom", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.invertAxisZoom = GUILayout.Toggle(this.target.invertAxisZoom, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- }
- GUILayout.Space(8f);
- this.showMouseOptions = GUILayout.Toggle(this.showMouseOptions, " Show Mouse Input Options", new GUILayoutOption[0]);
- GUILayout.Space(4f);
- if (this.showMouseOptions)
- {
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Mouse Controls", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.mouseControl = GUILayout.Toggle(this.target.mouseControl, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.mouseControl)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Click To Rotate", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.clickToRotate = GUILayout.Toggle(this.target.clickToRotate, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.clickToRotate)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Left Click", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.leftClickToRotate = GUILayout.Toggle(this.target.leftClickToRotate, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Right Click", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.rightClickToRotate = GUILayout.Toggle(this.target.rightClickToRotate, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUI.color = new Color(1f, 1f, 1f);
- }
- GUILayout.Space(8f);
- this.showKeyboardOptions = GUILayout.Toggle(this.showKeyboardOptions, " Show Keyboard Input Options", new GUILayoutOption[0]);
- GUILayout.Space(4f);
- if (this.showKeyboardOptions)
- {
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Keyboard Controls", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.keyboardControl = GUILayout.Toggle(this.target.keyboardControl, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- }
- GUILayout.Space(8f);
- this.showAutoRotateOptions = GUILayout.Toggle(this.showAutoRotateOptions, " Show Auto-Rotate Options", new GUILayoutOption[0]);
- GUILayout.Space(4f);
- if (this.showAutoRotateOptions)
- {
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Auto Rotate", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.autoRotateOn = GUILayout.Toggle(this.target.autoRotateOn, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.autoRotateOn)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Reverse", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.autoRotateReverse = GUILayout.Toggle(this.target.autoRotateReverse, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Rotate Speed", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.autoRotateSpeed = GUILayout.HorizontalSlider(this.target.autoRotateSpeed, 0.01f, 20f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.autoRotateSpeed.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUI.color = new Color(1f, 1f, 1f);
- }
- GUILayout.Space(8f);
- this.showSpinOptions = GUILayout.Toggle(this.showSpinOptions, " Show Spin Options", new GUILayoutOption[0]);
- GUILayout.Space(4f);
- if (this.showSpinOptions)
- {
- GUILayout.Label("Hold Left-CTRL and throw to spin.", new GUILayoutOption[0]);
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Spin Enabled", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.SpinEnabled = GUILayout.Toggle(this.target.SpinEnabled, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.SpinEnabled)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Max Spin Speed", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.maxSpinSpeed = GUILayout.HorizontalSlider(this.target.maxSpinSpeed, 0.01f, 5f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.maxSpinSpeed.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUI.color = new Color(1f, 1f, 1f);
- }
- GUILayout.Space(8f);
- this.showCollisionOptions = GUILayout.Toggle(this.showCollisionOptions, " Show Collision Options", new GUILayoutOption[0]);
- GUILayout.Space(4f);
- if (this.showCollisionOptions)
- {
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Collision Enabled", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.cameraCollision = GUILayout.Toggle(this.target.cameraCollision, string.Empty, new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- if (!this.target.cameraCollision)
- {
- GUI.color = new Color(0.5f, 0.5f, 0.5f);
- }
- GUILayout.BeginHorizontal(new GUILayoutOption[0]);
- GUILayout.Label("Collision Radius", new GUILayoutOption[]
- {
- GUILayout.Width((float)this.LabelWidth)
- });
- this.target.collisionRadius = GUILayout.HorizontalSlider(this.target.collisionRadius, 0.01f, 1f, new GUILayoutOption[]
- {
- GUILayout.Width((float)this.SliderWidth)
- });
- GUILayout.Label(this.target.collisionRadius.ToString("F"), new GUILayoutOption[0]);
- GUILayout.EndHorizontal();
- GUI.color = new Color(1f, 1f, 1f);
- }
- GUILayout.EndScrollView();
- GUILayout.EndArea();
- }
- public UltimateOrbitCamera target;
- private int height;
- private bool showOrbitOptions;
- private bool showMouseOptions;
- private bool showKeyboardOptions;
- private bool showAutoRotateOptions;
- private bool showSpinOptions;
- private bool showCollisionOptions;
- private int LabelWidth = 80;
- private int SliderWidth = 180;
- private Vector2 scrollPos = new Vector2(0f, 0f);
- }
|