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); }