-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSofaLaserModelEditor.cs
More file actions
67 lines (57 loc) · 2.48 KB
/
SofaLaserModelEditor.cs
File metadata and controls
67 lines (57 loc) · 2.48 KB
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
using UnityEngine;
using UnityEditor;
using SofaUnity;
using System.Collections.Generic;
namespace SofaUnity
{
/// <summary>
/// Editor class corresponding to @sa SofaLaserModelEditor
/// This editor is a specialization of @sa SofaRayCasterEditor to add Laser display parameters
/// Provide method to create SofaLaserModel from Unity Menu
/// </summary>
[CustomEditor(typeof(SofaLaserModel), true)]
public class SofaLaserModelEditor : SofaRayCasterEditor
{
/// <summary>
/// Add SofaLaserModel creation to SofaUnity Menu
/// </summary>
/// <returns>Pointer to the SofaLaserModel GameObject</returns>
[MenuItem("Tools/SofaUnity/SofaComponent/SofaLaserModel")]
[MenuItem("GameObject/Tools/SofaUnity/SofaComponent/SofaLaserModel")]
public static GameObject CreateNew()
{
GameObject go = new GameObject("SofaLaserModel");
go.AddComponent<SofaLaserModel>();
if (Selection.activeTransform != null)
go.transform.parent = Selection.activeTransform;
return go;
}
/// Method to create parameters GUI
public override void OnInspectorGUI()
{
// display SofaRayCasterEditor first
base.OnInspectorGUI();
SofaLaserModel model = this.target as SofaLaserModel;
if (model == null)
return;
EditorGUILayout.Separator();
EditorGUILayout.Separator();
model.DrawLight = EditorGUILayout.Toggle("Draw Laser Light", model.DrawLight);
if (model.DrawLight)
{
model.LaserStartColor = EditorGUILayout.ColorField("Laser Color", model.LaserStartColor);
EditorGUILayout.Separator();
EditorGUILayout.Separator();
}
model.DrawLaser = EditorGUILayout.Toggle("Draw Laser Particles", model.DrawLaser);
if (model.DrawLaser)
{
model.LaserWidth = EditorGUILayout.FloatField("Laser Width", model.LaserWidth);
if (!model.DrawLight)
model.LaserStartColor = EditorGUILayout.ColorField("Laser start Color", model.LaserStartColor);
model.LaserEndColor = EditorGUILayout.ColorField("Laser end Color", model.LaserEndColor);
model.m_particleMat = EditorGUILayout.ObjectField("Laser Material", model.m_particleMat, typeof(Material)) as Material;
}
}
}
}