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