1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
using System.Collections.Generic;
using System.Drawing;
using UnityEngine;
class REPL
{
public static Transform footCenter;
public static void StartREPL()
{
//return;
AddHeightBox();
AddCamera();
AddRigidbodyDebug();
AddCubes();
AddFootCenter();
}
public static void AddCamera()
{
GameObject camera = GameObject.Find("WanderCamera");
if (camera != null)
{
GameObject.DestroyImmediate(camera);
}
camera = new GameObject();
camera.name = "WanderCamera";
camera.AddComponent<Camera>();
camera.AddComponent<SimpleMoveCamera>();
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<MonoBehaviour>();
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<DebugRigidBody>();
//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<string, CubeParams> targets = new Dictionary<string, CubeParams>{
{"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<MonoBehaviour>();
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<DebugRigidBody>();
drb.mode = target.Value.mode;
drb.color = target.Value.color;
drb.cubeLen = target.Value.size;
}
}
}
public static void AddHeightBox()
{
//float height = 2;
//GameObject cube = new GameObject();
//cube.transform.position = new Vector3(4.39f, 31.397f + height / 2.0f, -9.96f);
//var drb = cube.AddComponent<DebugRigidBody>();
//drb.mode = DebugRigidBody.EMode.Cube;
//drb.color = UnityEngine.Color.red;
//drb.cubeLen = height;
}
public static void AddFootCenter()
{
float height = 2;
GameObject cube = new GameObject();
footCenter = cube.transform;
cube.transform.position = new Vector3(4.39f, 31.397f + height / 2.0f, -9.96f);
var drb = cube.AddComponent<DebugRigidBody>();
drb.mode = DebugRigidBody.EMode.Custom;
drb.color = UnityEngine.Color.white;
drb.cubeLen = 0.1f;
drb.customDraw = () => {
//Draw.Sphere(drb.transform.position, 0.05f);
};
}
}
|