Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using UnityEngine;
- namespace meta
- {
- public class Mod : MonoBehaviour
- {
- public Rect windowRect = new Rect(20, 20, 250, 300);
- //public RenderTexture renderTexture = new RenderTexture(450,300,32);
- //public Camera renderCamera = (Camera)Camera.Instantiate (Camera.main);
- public List<RenderTexture> renderTextureList = new List<RenderTexture>();
- public List<GameObject> cameraList = new List<GameObject>();
- public List<GameObject> cameraChildList = new List<GameObject>();
- public List<Rect> windowRectList = new List<Rect>();
- public bool listCameras = false;
- public int fullscreen = -1;
- public Vector2 ScrollPosition;
- public void Start() {
- //renderTexture.Create ();k
- }
- public void Update() {
- /**if (Input.GetKeyDown (KeyCode.C)) {
- renderTextureList.Add (new RenderTexture (450, 300, 32));
- cameraList.Add ((Camera)Camera.Instantiate (Camera.main));
- windowRectList.Add (new Rect (20, 20, 450, 300));
- renderTextureList [renderTextureList.Count - 1].Create ();
- }
- if (Input.GetKeyDown (KeyCode.R)) {
- renderTextureList = new List<RenderTexture>();
- cameraList = new List<Camera>();
- windowRectList = new List<Rect>();
- }**/
- GameObject.Find ("Main Camera").SetActive (true);
- for (int i=0;i<cameraList.Count;i++) {
- }
- if (Input.GetKeyDown (KeyCode.Escape) && fullscreen != -1) {
- windowRectList [fullscreen] = new Rect(0,0, 450, 300);
- fullscreen = -1;
- }
- }
- IEnumerator<WaitForSeconds> OnLevelLoadedFunc () {
- yield return new WaitForSeconds (1);
- if (GameObject.Find ("bgeL0")) {
- renderTextureList = new List<RenderTexture> ();
- cameraList = new List<GameObject> ();
- cameraChildList = new List<GameObject> ();
- windowRectList = new List<Rect> ();
- foreach (GameObject gameObject in GameObject.FindObjectsOfType<GameObject>()) {
- if (gameObject.name == "CamModCam") {
- Destroy (gameObject.transform.FindChild ("CamModCamChild").gameObject);
- Vector3 TempPos = gameObject.transform.position;
- Quaternion TempRot = new Quaternion ();
- TempRot.eulerAngles = gameObject.transform.rotation.eulerAngles;
- Destroy (gameObject);
- NewCam ();
- cameraList [cameraList.Count - 1].transform.position = TempPos;
- cameraList [cameraList.Count - 1].transform.rotation = TempRot;
- }
- }
- }
- }
- void OnLevelWasLoaded(int level) {
- //Debug.Log ("QUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACK");
- StartCoroutine(OnLevelLoadedFunc());
- }
- public void NewCam() {
- //Create's the rect for the camera's window
- windowRectList.Add (new Rect (20, 20, 450, 300));
- //Create's and add's the renderTexture
- renderTextureList.Add (new RenderTexture (450, 300, 32));
- renderTextureList [renderTextureList.Count - 1].Create ();
- //Create's the camera gameObject
- cameraList.Add (GameObject.CreatePrimitive (PrimitiveType.Cube));
- cameraList [cameraList.Count - 1].AddComponent<Camera> ();
- //Set's the camera propertries
- cameraList [cameraList.Count - 1].transform.position = new Vector3 (0, 1, 0);
- cameraList [cameraList.Count - 1].name = "CamModCam";
- //cameraList [cameraList.Count - 1].tag = "CamModCamTag";
- cameraList [cameraList.Count - 1].collider.enabled = false;
- cameraList [cameraList.Count - 1].camera.enabled = true;
- cameraList [cameraList.Count - 1].transform.parent = GameObject.Find ("bgeL0").transform;
- cameraList [cameraList.Count - 1].camera.targetTexture = renderTextureList [renderTextureList.Count - 1];
- cameraList [cameraList.Count - 1].renderer.material.color = Color.black;
- cameraChildList.Add (GameObject.CreatePrimitive (PrimitiveType.Plane));
- cameraChildList [cameraChildList.Count - 1].transform.localScale = new Vector3 (0.1f, 1, 0.1f);
- cameraChildList [cameraChildList.Count - 1].transform.position = new Vector3 (0, 1, 0.53f);
- cameraChildList [cameraChildList.Count - 1].transform.Rotate (90, 0, 0);
- cameraChildList [cameraChildList.Count - 1].transform.parent = cameraList [cameraList.Count - 1].transform;
- cameraChildList [cameraChildList.Count - 1].name = "CamModCamChild";
- cameraChildList [cameraChildList.Count - 1].collider.enabled = false;
- }
- void OnGUI() {
- for (int i=0; i<windowRectList.Count;i++) {
- windowRectList [i] = GUI.Window (i+1, windowRectList [i], DoMyWindow, "");
- }
- windowRect = GUI.Window(0, windowRect, DoMyWindowConf, "Camera Config");
- }
- void DoMyWindow(int windowID) {
- //PUT STUFF TO GO IN WINDOW HERE
- try {
- cameraList[windowID-1].camera.targetTexture = renderTextureList[windowID-1];
- } catch {
- //Destroy (cameraList [windowID - 1]);
- }
- if (fullscreen != -1) {
- GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), renderTextureList [windowID - 1], ScaleMode.StretchToFill, false);
- } else {
- GUI.DrawTexture (new Rect (0, 0, 450, 300), renderTextureList [windowID - 1], ScaleMode.StretchToFill, false);
- }
- //DONE
- if (fullscreen == -1) {
- GUI.DragWindow ();
- }
- }
- void DoMyWindowConf(int windowID) {
- GUILayout.BeginHorizontal ();
- if (GUILayout.Button ("Remove All Cameras")) {
- foreach (GameObject gameObject in GameObject.FindObjectsOfType<GameObject>()) {
- if (gameObject.name == "CamModCam" || gameObject.name == "CamModCamChild") {
- GameObject.Destroy (gameObject);
- }
- }
- renderTextureList = new List<RenderTexture>();
- cameraList = new List<GameObject>();
- cameraChildList = new List<GameObject>();
- windowRectList = new List<Rect> ();
- }
- if (GUILayout.Button ("Add A Camera")) {
- if (GameObject.Find ("bgeL0") != null) {
- NewCam ();
- }
- }
- GUILayout.EndHorizontal ();
- ScrollPosition = GUILayout.BeginScrollView (ScrollPosition, true, false);
- int i = 0;
- foreach (GameObject camera in cameraList) {
- GUILayout.BeginVertical ("Box");
- GUILayout.Label ("Move:");
- GUILayout.BeginHorizontal ();
- if (GUILayout.Button (new GUIContent("Forward","Forward"))) {
- camera.transform.position = new Vector3 (camera.transform.position.x+1, camera.transform.position.y, camera.transform.position.z);
- }
- if (GUILayout.Button (new GUIContent("Backward","Backward"))) {
- camera.transform.position = new Vector3 (camera.transform.position.x-1, camera.transform.position.y, camera.transform.position.z);
- }
- if (GUILayout.Button (new GUIContent("Left","Left"))) {
- camera.transform.position = new Vector3 (camera.transform.position.x, camera.transform.position.y, camera.transform.position.z+1);
- }
- if (GUILayout.Button (new GUIContent("Right","Right"))) {
- camera.transform.position = new Vector3 (camera.transform.position.x, camera.transform.position.y, camera.transform.position.z-1);
- }
- GUILayout.EndHorizontal ();
- GUILayout.BeginHorizontal ();
- if (GUILayout.Button (new GUIContent("Up","Move up"))) {
- camera.transform.position = new Vector3 (camera.transform.position.x, camera.transform.position.y+1, camera.transform.position.z);
- }
- if (GUILayout.Button (new GUIContent("Down","Move down"))) {
- camera.transform.position = new Vector3 (camera.transform.position.x, camera.transform.position.y-1, camera.transform.position.z);
- }
- GUILayout.EndHorizontal ();
- GUILayout.Label ("Rotate:");
- GUILayout.BeginHorizontal ();
- if (GUILayout.Button (new GUIContent("Up","Rotate up"))) {
- camera.transform.Rotate (new Vector3 (-90, 0, 0));
- }
- if (GUILayout.Button (new GUIContent("Down","Rotate down"))) {
- camera.transform.Rotate (new Vector3 (90, 0, 0));
- }
- if (GUILayout.Button (new GUIContent("Left","Rotate left"))) {
- camera.transform.Rotate (new Vector3 (0, -90, 0));
- }
- if (GUILayout.Button (new GUIContent("Right","Rotate right"))) {
- camera.transform.Rotate (new Vector3 (0, 90, 0));
- }
- GUILayout.EndHorizontal ();
- if (GUILayout.Button ("Set As Main Camera")) {
- windowRectList [i] = new Rect(0,0, Screen.width, Screen.height);
- fullscreen = i;
- }
- if (GUILayout.Button ("Toggle Invisibility")) {
- if (camera.renderer.enabled == true) {
- camera.renderer.enabled = false;
- camera.transform.FindChild ("CamModCamChild").renderer.enabled = false;
- } else {
- camera.renderer.enabled = true;
- camera.transform.FindChild ("CamModCamChild").renderer.enabled = true;
- }
- }
- GUILayout.EndVertical ();
- i++;
- }
- GUILayout.EndScrollView ();
- GUI.DragWindow ();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement