|
1 | 1 | #if UNITY_EDITOR |
2 | | - using UnityEngine; |
| 2 | +using UnityEngine; |
3 | 3 |
|
4 | | - namespace MccDev260.GizmoTool |
| 4 | +namespace MccDev260.GizmoTool |
| 5 | +{ |
| 6 | + [ExecuteInEditMode] |
| 7 | + public class GizmoDrawer : MonoBehaviour |
5 | 8 | { |
6 | | - [ExecuteInEditMode] |
7 | | - public class GizmoDrawer : MonoBehaviour |
8 | | - { |
9 | | - [SerializeField] private bool drawOnSelectOnly; |
| 9 | + [SerializeField] private bool drawOnSelectOnly; |
| 10 | + |
| 11 | + #region Properties |
| 12 | + //Shared |
| 13 | + [Tooltip("Sets the origin of the gizmo to the position of this transform.")] |
| 14 | + [HideInInspector] public Transform originTransform; |
| 15 | + [Tooltip("Directly enter world postion for the gizmo origin.")] |
| 16 | + [HideInInspector] public Vector3 originPos; |
| 17 | + [HideInInspector] public GizmoType gizmoType; |
| 18 | + [HideInInspector] public Color gizmoColor = Color.blue; |
| 19 | + |
| 20 | + //Icon |
| 21 | + [Tooltip("Source should be placed in Assets/Gizmos folder.")] |
| 22 | + [HideInInspector] public string filePathString; |
| 23 | + [HideInInspector] public bool allowScaling; |
10 | 24 |
|
11 | | - #region Properties |
12 | | - //Shared |
13 | | - [HideInInspector] public Transform originTransform; |
14 | | - [HideInInspector] public Vector3 originPos; |
15 | | - [HideInInspector] public GizmoType gizmoType; |
16 | | - [HideInInspector] public Color gizmoColor = Color.blue; |
| 25 | + //Sphere |
| 26 | + [HideInInspector] public float floatRadius = 1f; |
| 27 | + //Cube |
| 28 | + [HideInInspector] public bool uniformScale; // Not implemented yet. |
17 | 29 |
|
18 | | - //Icon |
19 | | - [HideInInspector] public string filePathString; |
20 | | - [HideInInspector] public bool allowScaling; |
| 30 | + // Mesh |
| 31 | + [HideInInspector] public Mesh mesh; |
| 32 | + [Tooltip("Copy the transform values from the object this script is on.")] |
| 33 | + [HideInInspector] public bool useAttachedTransformValues; |
| 34 | + [Tooltip("Use the mesh thats on this object as the gizmo.")] |
| 35 | + [HideInInspector] public bool useMeshOnFilter; |
| 36 | + [Tooltip("Copy values from the transform referenced as the origin.")] |
| 37 | + [HideInInspector] public bool useOriginTransformValues; |
21 | 38 |
|
22 | | - //Sphere |
23 | | - [HideInInspector] public float floatRadius = 1f; |
24 | | - //Cube |
25 | | - [HideInInspector] public bool uniformScale; |
26 | | - [HideInInspector] public Vector3 scale = Vector3.one; |
| 39 | + [HideInInspector] public Vector3 meshRotation; |
| 40 | + [HideInInspector] public Vector3 scale = Vector3.one; |
27 | 41 |
|
28 | | - // Mesh |
29 | | - [HideInInspector] public Mesh mesh; |
30 | | - [HideInInspector] public Vector3 meshRotation; |
31 | | - [HideInInspector] public bool useAttachedTransformValues; |
32 | | - [HideInInspector] public bool useMeshOnFilter; |
33 | | - //Line |
34 | | - [HideInInspector] public Transform targetTransform; |
35 | | - [HideInInspector] public Vector3 targetPosition; |
| 42 | + //Line |
| 43 | + [HideInInspector] public Transform targetTransform; |
| 44 | + [HideInInspector] public Vector3 targetPosition; |
36 | 45 |
|
37 | | - //LineList & LineStrip |
38 | | - [HideInInspector] public Vector3[] points = new Vector3[0]; |
| 46 | + //LineList & LineStrip |
| 47 | + [HideInInspector] public Vector3[] points = new Vector3[0]; |
39 | 48 |
|
40 | | - [HideInInspector] public bool useTransformArray; |
41 | | - [HideInInspector] public Transform[] transformPoints = new Transform[0]; |
| 49 | + [HideInInspector] public bool useTransformArray; |
| 50 | + [HideInInspector] public Transform[] transformPoints = new Transform[0]; |
42 | 51 |
|
43 | | - [HideInInspector] public bool looped; |
| 52 | + [HideInInspector] public bool looped; |
44 | 53 |
|
45 | | - // GUI Texture |
46 | | - /// <summary> |
47 | | - /// The size and position of the texture on the "screen" defined by the XY plane. |
48 | | - /// </summary> |
49 | | - [HideInInspector] public Rect screenRect; |
50 | | - /// <summary> |
51 | | - /// The texture to be displayed. |
52 | | - /// </summary> |
53 | | - [HideInInspector] public Texture texture; |
54 | | - /// <summary> |
55 | | - /// An optional material to apply the texture. |
56 | | - /// </summary> |
57 | | - [HideInInspector] public Material mat; |
58 | | - #endregion |
| 54 | + // GUI Texture |
| 55 | + /// <summary> |
| 56 | + /// The size and position of the texture on the "screen" defined by the XY plane. |
| 57 | + /// </summary> |
| 58 | + [HideInInspector] public Rect screenRect; |
| 59 | + /// <summary> |
| 60 | + /// The texture to be displayed. |
| 61 | + /// </summary> |
| 62 | + [HideInInspector] public Texture texture; |
| 63 | + /// <summary> |
| 64 | + /// An optional material to apply the texture. |
| 65 | + /// </summary> |
| 66 | + [HideInInspector] public Material mat; |
| 67 | + #endregion |
59 | 68 |
|
60 | | - private void OnDrawGizmosSelected() |
61 | | - { |
62 | | - if (drawOnSelectOnly) |
63 | | - GizmoTool.DrawGizmo(this); |
64 | | - } |
| 69 | + private void OnDrawGizmosSelected() |
| 70 | + { |
| 71 | + if (drawOnSelectOnly) |
| 72 | + GizmoTool.DrawGizmo(this); |
| 73 | + } |
65 | 74 |
|
66 | | - private void OnDrawGizmos() |
67 | | - { |
68 | | - if (!drawOnSelectOnly) |
69 | | - GizmoTool.DrawGizmo(this); |
70 | | - } |
| 75 | + private void OnDrawGizmos() |
| 76 | + { |
| 77 | + if (!drawOnSelectOnly) |
| 78 | + GizmoTool.DrawGizmo(this); |
71 | 79 | } |
72 | 80 | } |
| 81 | +} |
73 | 82 | #endif |
0 commit comments