public void Start() { SetupGoose(); // Slightly larger GUI style for labels _guiStyle = new GUIStyle(); _guiStyle.fontSize = Screen.height * 2 / 100; _guiStyle.normal.textColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); // Screen Text Display _screenTextDisplay = new ScreenTextDisplay(); _screenTextDisplay.SetStartPosition(new Vector2(20f, 20f)); _screenTextDisplay.Clear(); _foundObjects = new List <GameObject>(); _finderString = ""; }
public void OnGUI() { _screenTextDisplay.Clear(); int screenWidth = Screen.width, screenHeight = Screen.height; _screenTextDisplay.AddText("Goose Nest v0.1"); _screenTextDisplay.AddTextAtPosition(string.Format("Total scenes: {0}", SceneManager.sceneCountInBuildSettings), new Vector2(screenWidth - 500, _screenTextDisplay.GetCurrentPosition().y)); _screenTextDisplay.AddText(string.Format("Scenes loaded: {0}", SceneManager.sceneCount)); _screenTextDisplay.AddText(string.Format("Active scene: {0}", SceneManager.GetActiveScene().name)); //for(int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; sceneIndex++) //{ // _screenTextDisplay.AddText(string.Format("Loaded scene name: {0}", SceneManager.GetSceneAt(sceneIndex).name)); //} for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCountInBuildSettings; sceneIndex++) { _screenTextDisplay.AddText(string.Format("Built scene path: {0}", SceneUtility.GetScenePathByBuildIndex(sceneIndex))); } if (GUI.Button(new Rect((screenWidth - 300), 110, 80, 30), "Load Game")) { SceneManager.LoadScene("main", LoadSceneMode.Additive); } if (GUI.Button(new Rect((screenWidth - 300) + 90, 110, 80, 30), "Load Loading")) { SceneManager.LoadScene("loading"); } //_screenTextDisplay.SetPosition(new Vector2(20, screenHeight - 100)); float listLength = 0; if (_lastClickedObjects.Count > 0) { listLength = _lastClickedObjects.Count; } if (_collectiveObjects.Count > 0) { listLength = _collectiveObjects.Count; } if (listLength <= 0f) { focusedObject = null; } listLength *= 24f; if (listLength > 0f) { _objectsScrollPosition = GUI.BeginScrollView(new Rect(20, screenHeight - 350, 500, 300), _objectsScrollPosition, new Rect(0, 0, 520, listLength)); Vector2 viewPosition = new Vector2(0f, 0f); Vector2 viewStep = new Vector2(0f, 24f); Vector2 viewSize = new Vector2(500f, 24f); for (int index = 0; index < _lastClickedObjects.Count; index++) { if (GUI.Button(new Rect(viewPosition, viewSize), string.Format("{0} : {1}", _lastClickedObjects[index].Object, _lastClickedObjects[index].Object.GetComponents <Component>().Length))) { focusedObject = _lastClickedObjects[index].Object; _componentScrollPosition = Vector2.zero; } viewPosition += viewStep; //_screenTextDisplay.AddText(string.Format("{0} : {1}", _lastClickedObjects[index].Object, _lastClickedObjects[index].Object.GetComponents<Component>().Length)); } for (int index = 0; index < _collectiveObjects.Count; index++) { if (GUI.Button(new Rect(viewPosition, viewSize), string.Format("{0}", _collectiveObjects[index].name))) { focusedObject = _collectiveObjects[index] as GameObject; _componentScrollPosition = Vector2.zero; } viewPosition += viewStep; } GUI.EndScrollView(); } if (focusedObject) { float componentListLength = 0; Component[] components = focusedObject.GetComponents <Component>(); if (components.Length > 0) { componentListLength = components.Length * 24; } _componentScrollPosition = GUI.BeginScrollView(new Rect(550, screenHeight - 350, 400, 300), _componentScrollPosition, new Rect(0, 0, 420, componentListLength)); Vector2 viewPosition = new Vector2(0f, 0f); Vector2 viewStep = new Vector2(0f, 24f); Vector2 viewSize = new Vector2(400f, 24f); for (int index = 0; index < components.Length; index++) { GUI.Label(new Rect(viewPosition, viewSize), string.Format("{0} - {1}", components[index].name, components[index].GetType())); viewPosition += viewStep; } } _screenTextDisplay.DrawTextToGUI(); }
public void OnGUI() { _screenTextDisplay.Clear(); int w = Screen.width, h = Screen.height; GUIStyle style = new GUIStyle(); Rect rect = new Rect(0, 0, w, h * 2 / 100); style.alignment = TextAnchor.UpperRight; style.fontSize = h * 2 / 100; style.normal.textColor = new Color(1.0f, 1.0f, 1.0f, 1.0f); float msec = _deltaTime * 1000.0f; float fps = 1.0f / _deltaTime; string text = string.Format("{0:0.0} ms ({1:0.} fps)", msec, fps); GUI.Label(rect, text, style); if (!_menuEnabled) { if (_goose) { Vector3 _gs_position = _goose.gameObject.transform.position; Quaternion _gs_rotation = _goose.gameObject.transform.rotation; Vector3 _gs_velocity = _goose.GetComponent <Rigidbody>().velocity; string _position_string = string.Format("Position: ({0}, {1}, {2})", _gs_position.x.ToString("F4"), _gs_position.y.ToString("F4"), _gs_position.z.ToString("F4")); string _rotation_string = string.Format("Rotation: ({0}, {1}, {2}, {3})", _gs_rotation.x.ToString("F4"), _gs_rotation.y.ToString("F4"), _gs_rotation.z.ToString("F4"), _gs_rotation.w.ToString("F4")); string _velocity_string = string.Format("Velocity: ({0}, {1}, {2})", _gs_velocity.x.ToString("F4"), _gs_velocity.y.ToString("F4"), _gs_velocity.z.ToString("F4")); _screenTextDisplay.AddText(_position_string); _screenTextDisplay.AddText(_rotation_string); _screenTextDisplay.AddText(_velocity_string); } if (_cloneGoose) { _screenTextDisplay.AddText("Clone Position: (" + _cloneGoose.gameObject.transform.position + ")"); _screenTextDisplay.AddText("Clone Rotation: (" + _cloneGoose.gameObject.transform.rotation + ")"); _screenTextDisplay.AddText("Clone Velocity: " + _cloneGoose.GetComponent <Rigidbody>().velocity); } } if (_menuEnabled) { GUI.Box(new Rect(20, 20, Screen.width / 2, Screen.height / 2), "Goose Nest"); _screenTextDisplay.AddText("Spawn a Tracking Sphere: CTRL+S"); _screenTextDisplay.AddText("Creates Clone Goose: CTRL+P"); _screenTextDisplay.AddText("Delete All Humans: CTRL+B"); } if (_finderDisplayed) { _finderString = GUI.TextField(new Rect(w - 300, 80, 200, 28), _finderString); if (GUI.Button(new Rect(w - 300, 110, 60, 30), "Part")) { FindObjectsWithPartial(_finderString); } if (GUI.Button(new Rect((w - 300) + 70, 110, 60, 30), "All")) { FindAllGameObjects(); } if (GUI.Button(new Rect((w - 300) + 140, 110, 60, 30), "Part Log")) { FindObjectsWithPartial(_finderString, true); } foreach (GameObject foundObject in _foundObjects) { _screenTextDisplay.AddText(foundObject.name); } } _screenTextDisplay.DrawTextToGUI(); }