-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSofaPlaneEditor.cs
More file actions
96 lines (82 loc) · 3.41 KB
/
SofaPlaneEditor.cs
File metadata and controls
96 lines (82 loc) · 3.41 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
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
using UnityEngine;
using UnityEditor;
using SofaUnity;
namespace SofaUnity
{
/// <summary>
/// Editor class corresponding to @sa SofaPlane object
/// This class inherite from @sa SofaGridEditor and will add specific parameter for Plane deformable object.
/// Provide create method to create SofaPlane from Unity Menu and register it inside DAGNodeManager
/// Provide interface for user interaction
/// </summary>
[CustomEditor(typeof(SofaPlane), true)]
public class SofaPlaneEditor : SofaGridEditor
{
/// <summary>
/// Add SofaPlane Object creation to the SofaUnity Menu
/// </summary>
/// <returns>Pointer to the SofaPlane GameObject</returns>
[MenuItem("Tools/SofaUnity/PrimitiveObject/SofaPlane")]
[MenuItem("GameObject/Tools/SofaUnity/SofaPrimitiveObject/SofaPlane")]
new public static GameObject CreateNew()
{
SofaDAGNode parentDagN = GetDAGNodeSelected();
if (parentDagN == null)
return null;
GameObject go = new GameObject("SofaPlane");
go.AddComponent<SofaPlane>();
SofaDAGNodeManager nodeMgr = parentDagN.m_sofaContext.NodeGraphMgr;
if (nodeMgr != null)
nodeMgr.RegisterCustomObject(go, parentDagN, true);
else
Debug.LogError("Error creating SofaPlane object. Can't access SofaDAGNodeManager.");
return go;
}
/// <summary>
/// Method to set the UI of the SofaPlane GameObject
/// </summary>
public override void OnInspectorGUI()
{
// call SofaGrid and SofaDeformableMesh UI creation
base.OnInspectorGUI();
}
}
/// <summary>
/// Editor class corresponding to @sa SofaRigidPlane object
/// This class inherite from @sa SofaGridEditor and will add specific parameter for Plane regid object.
/// Provide create method to create SofaRigidPlane from Unity Menu and register it inside DAGNodeManager
/// Provide interface for user interaction
/// </summary>
[CustomEditor(typeof(SofaRigidPlane), true)]
public class SofaRigidPlaneEditor : SofaGridEditor
{
/// <summary>
/// Add SofaRigidPlane Object creation to the SofaUnity Menu
/// </summary>
/// <returns>Pointer to the SofaRigidPlane GameObject</returns>
[MenuItem("Tools/SofaUnity/PrimitiveObject/SofaRigidPlane")]
[MenuItem("GameObject/Tools/SofaUnity/SofaPrimitiveObject/SofaRigidPlane")]
new public static GameObject CreateNew()
{
SofaDAGNode parentDagN = GetDAGNodeSelected();
if (parentDagN == null)
return null;
GameObject go = new GameObject("SofaRigidPlane");
go.AddComponent<SofaRigidPlane>();
SofaDAGNodeManager nodeMgr = parentDagN.m_sofaContext.NodeGraphMgr;
if (nodeMgr != null)
nodeMgr.RegisterCustomObject(go, parentDagN, true);
else
Debug.LogError("Error creating SofaRigidPlane object. Can't access SofaDAGNodeManager.");
return go;
}
/// <summary>
/// Method to set the UI of the SofaRigidPlane GameObject
/// </summary>
public override void OnInspectorGUI()
{
// call SofaRigidGrid and SofaRigidMesh UI creation
base.OnInspectorGUI();
}
}
}