Skip to content

Commit 752a365

Browse files
authored
[src] Add binding and support to display SOFA version into SofaContext inspector (#248)
* SOFAU3D-10 #done #time 1h
1 parent cd6794d commit 752a365

3 files changed

Lines changed: 23 additions & 0 deletions

File tree

Core/Plugins/SofaUnityAPI/SofaContextAPI.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class SofaContextAPI : IDisposable
1818
bool m_isDisposed = false;
1919

2020
private bool m_isReady = false;
21+
public string m_sofaVersion = "Unknown version";
2122

2223
public static string getResourcesPath()
2324
{
@@ -105,6 +106,8 @@ public SofaContextAPI(bool async)
105106
Debug.LogError("SofaContextAPI scene creation return: " + SofaDefines.msg_error[res]);
106107
m_isReady = false;
107108
}
109+
110+
m_sofaVersion = sofaPhysicsAPI_version(m_native);
108111
}
109112

110113
/// Destructor
@@ -559,6 +562,9 @@ public void SofaKeyReleaseEvent(int keyId)
559562
[DllImport("SofaVerseAPI", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
560563
public static extern string sofaPhysicsAPI_APIName(IntPtr obj);
561564

565+
[DllImport("SofaVerseAPI", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
566+
public static extern string sofaPhysicsAPI_version(IntPtr obj);
567+
562568

563569
/// Bindings to create or load an existing simulation scene
564570
[DllImport("SofaVerseAPI")]

Core/Scripts/Editor/SofaContextEditor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ public override void OnInspectorGUI()
6666
logoGUIStyle.border = new RectOffset(0, 0, 0, 0);
6767
EditorGUILayout.LabelField(new GUIContent(SofaLogo), GUILayout.MinHeight(100.0f), GUILayout.ExpandWidth(true));
6868

69+
// Add field for Sofa version
70+
EditorGUI.BeginDisabledGroup(true);
71+
EditorGUILayout.TextField("Sofa Version", context.SofaVersion);
72+
EditorGUI.EndDisabledGroup();
73+
EditorGUILayout.Separator();
74+
6975
// Add field for gravity
7076
context.Gravity = EditorGUILayout.Vector3Field("Gravity", context.Gravity);
7177
EditorGUILayout.Separator();

Core/Scripts/SofaContext.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ public SofaGraphicAPI SofaGraphicAPI
109109
get { return m_graphicAPI; }
110110
}
111111

112+
public string SofaVersion
113+
{
114+
get
115+
{
116+
if (m_impl != null)
117+
return m_impl.m_sofaVersion;
118+
else
119+
return "undefined";
120+
}
121+
}
122+
112123
/// Getter/Setter of current gravity @see m_gravity
113124
public Vector3 Gravity
114125
{

0 commit comments

Comments
 (0)