using System.Collections.Generic; using System.Drawing; using UnityEngine; class REPL { public static void StartREPL() { AddCamera(); AddRigidbodyDebug(); AddCubes(); } public static void AddCamera() { GameObject camera = GameObject.Find("WanderCamera"); if (camera != null) { GameObject.DestroyImmediate(camera); } camera = new GameObject(); camera.name = "WanderCamera"; camera.AddComponent(); camera.AddComponent(); GameObject wanderCam = GameObject.Find("WanderCamera"); GameObject player = GameObject.Find("Player"); if (player != null) { wanderCam.transform.position = player.transform.position; } wanderCam.transform.position = new Vector3(1.21f, 33.92f, -10.4f); wanderCam.transform.rotation = Quaternion.Euler(25.95f, 75, 0); } public static void AddRigidbodyDebug() { string[] targets = { "Head", "Neck", "Torso", "Arm_Right", "Arm_Left", "Hand_Right", "Hand_Left", "Hip", "Leg_Left", "Leg_Right", "Foot_Left", "Foot_Right", "Knee_Left", "Knee_Right", }; for(int i = 0; i < targets.Length; ++i) { string target = targets[i]; GameObject go = GameObject.Find(target); if(go != null) { var comps = go.gameObject.GetComponents(); if (comps != null) { for (int j = 0; j < comps.Length; j++) { if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") { UnityEngine.Object.DestroyImmediate(comps[j]); } } } Debug.Log(go.name); var drb = go.AddComponent(); //drb.mode = DebugRigidBody.EMode.Cube; //drb.color = Color.green; } } } public struct CubeParams { public UnityEngine.Color color; public float size; public DebugRigidBody.EMode mode; } public static void AddCubes() { Dictionary targets = new Dictionary{ {"CameraPos", new CubeParams(){ color = UnityEngine.Color.red, size = 0.2f, mode = DebugRigidBody.EMode.Cube } }, {"Main Camera", new CubeParams(){ color = UnityEngine.Color.white, size = 0.05f, mode = DebugRigidBody.EMode.Axis_Cube } }, {"RotationTarget", new CubeParams(){ color = UnityEngine.Color.green, size = 0.05f, mode = DebugRigidBody.EMode.Axis_Cube } }, //{"AvaragePosition", new CubeParams(){ color = UnityEngine.Color.blue, size = 0.2f, mode = DebugRigidBody.EMode.Axis_Cube } }, }; foreach(var target in targets) { string name = target.Key; GameObject go = GameObject.Find(name); if (go != null) { var comps = go.gameObject.GetComponents(); if (comps != null) { for (int j = 0; j < comps.Length; j++) { if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2") { UnityEngine.Object.DestroyImmediate(comps[j]); } } } Debug.Log(go.name); var drb = go.AddComponent(); drb.mode = target.Value.mode; drb.color = target.Value.color; drb.cubeLen = target.Value.size; } } } }