-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSofaRayCasterEditor.cs
More file actions
57 lines (49 loc) · 2.3 KB
/
Copy pathSofaRayCasterEditor.cs
File metadata and controls
57 lines (49 loc) · 2.3 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
using UnityEngine;
using UnityEditor;
using SofaUnity;
using SofaUnityAPI;
using System.Collections.Generic;
namespace SofaUnity
{
/// <summary>
/// Editor class corresponding to @sa SofaRayCaster
/// Provide interface for RayCaster parameters like origin, direction and length and option to draw it.
/// Provide interface for SofaRayCaster like the type of interaction and option to activate and start on play.
/// </summary>
[CustomEditor(typeof(SofaRayCaster), true)]
public class SofaRayCasterEditor : Editor
{
/// Method to create parameters GUI
public override void OnInspectorGUI()
{
SofaRayCaster model = this.target as SofaRayCaster;
if (model == null)
return;
/// RayCaster inspector
model.Origin = EditorGUILayout.Vector3Field("Ray Origin", model.Origin);
model.Direction = EditorGUILayout.Vector3Field("Ray Direction", model.Direction);
model.Length = EditorGUILayout.FloatField("Ray Length", model.Length);
model.ActivateRay = EditorGUILayout.Toggle("Activate Ray", model.ActivateRay);
model.m_drawRay = EditorGUILayout.Toggle("Draw Ray", model.m_drawRay);
if (model.m_drawRay)
{
EditorGUILayout.Separator();
model.RayWidth = EditorGUILayout.FloatField("Ray Width", model.RayWidth);
model.RayColor = EditorGUILayout.ColorField("Ray Color", model.RayColor);
}
EditorGUILayout.Separator();
/// SofaRayCaster inspector
model.RayInteractionType = (SofaDefines.SRayInteraction)EditorGUILayout.EnumPopup("Tool interaction", model.RayInteractionType);
if (model.RayInteractionType != SofaDefines.SRayInteraction.None)
{
model.startOnPlay = EditorGUILayout.Toggle("StartOnPlay mode", model.startOnPlay);
model.ActivateTool = EditorGUILayout.Toggle("Activate Tool", model.ActivateTool);
}
if (model.RayInteractionType == SofaDefines.SRayInteraction.AttachTool)
{
EditorGUILayout.Separator();
model.AttachStiffness = EditorGUILayout.FloatField("Tool Attach Stiffness", model.AttachStiffness);
}
}
}
}