Newer
Older
Marco Zimmer
committed
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
using UnityEngine;
/* ############################
* ## Show Size Editor Addon ##
* ## This script reports ##
* ## the size of a object ##
* ## in x,y and z axis'. ##
* ## All work by Eric5h5 ##
* ##forum.unity3d.com/threa ##
* ## ds/object-size.19991 ##
* ## C# conversion and warn ##
* ##ing fix by Nsomnia of ##
* ## BlenderTek.com and last##
* ## function by justinlloyd##
* ############################ */
class ShowSize : EditorWindow
{
[MenuItem("Window/ShowSize")]
static void Init()
{
// Get existing open window or if none, make a new one:
//Next line replaces old statment causing a warning in Unity 4.6 used to be "ShowSize sizeWindow = new ShowSize();"
ShowSize sizeWindow = ScriptableObject.CreateInstance(typeof(ShowSize)) as ShowSize;
sizeWindow.autoRepaintOnSceneChange = true;
sizeWindow.Show();
}
void OnGUI()
{
if (Selection.activeGameObject != null)
{
GameObject thisObject = Selection.activeObject as GameObject;
if (thisObject == null)
{
return;
}
MeshFilter mf = thisObject.GetComponent(typeof(MeshFilter)) as MeshFilter;
if (mf == null)
{ return; }
Mesh mesh = mf.sharedMesh;
if (mesh == null)
{ return; }
Vector3 size = mesh.bounds.size;
Vector3 scale = thisObject.transform.localScale;
GUILayout.Label("Size\n X: " + size.x * scale.x + "\n Y: " + size.y * scale.y + "\n Z: " + size.z * scale.z + "");
}
if (!LaserPointer.laserBool)
return;
RaycastHit laserHit = LaserPointer.laserHit;
GUILayout.Label("Laser Pointer:\n " + laserHit.transform.position.ToString() + "\n\n");
}
void Update()
{
Repaint();
}
}