File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -320,7 +320,8 @@ protected override void Reconnect_impl()
320320 {
321321 if ( m_impl != null )
322322 {
323- SofaLog ( "SofaDAGNode " + UniqueNameId + " already has a SofaDAGNodeAPI." , 2 ) ;
323+ // This is not an error if unity node is not deleted. The api is still there and jsut need to be reconnected.
324+ SofaLog ( "SofaDAGNode " + UniqueNameId + " already has a SofaDAGNodeAPI." , 0 ) ;
324325 return ;
325326 }
326327
Original file line number Diff line number Diff line change 33using System . Collections . Generic ;
44using UnityEngine ;
55using SofaUnity ;
6- using XCharts . Runtime ;
76
87namespace SofaUnity
98{
Original file line number Diff line number Diff line change @@ -184,10 +184,12 @@ void SceneFileSection(SofaContext context)
184184 EditorGUILayout . Separator ( ) ;
185185 }
186186
187+ EditorGUILayout . Separator ( ) ;
187188 // Label of the filename loaded
188189 EditorGUILayout . LabelField ( "Scene Filename: " , context . SceneFileMgr . SceneFilename ) ;
189190
190191 context . UnLoadScene = GUILayout . Button ( "Unload Scene file" ) ;
192+ context . ReloadScene = GUILayout . Button ( "Reload Sofa Scene file" ) ;
191193 EditorGUILayout . Separator ( ) ;
192194 }
193195
Original file line number Diff line number Diff line change @@ -150,19 +150,35 @@ public bool AsyncSimulation
150150 }
151151 }
152152
153-
153+ /// Setter to unload the current scene and clear the sofa context. Will call @sa ClearSofaScene.
154154 public bool UnLoadScene
155155 {
156156 set
157157 {
158158 if ( value && m_impl != null )
159159 {
160- Debug . Log ( "UnLoadScene " + value ) ;
160+ if ( m_log )
161+ Debug . Log ( "#### SofaContext UnLoadScene: " + value ) ;
162+
161163 ClearSofaScene ( ) ;
162164 }
163165 }
164166 }
165167
168+ /// Setter to reload the current scene. Will clear SOFA scene and reload it internally. Then will reconnect the graph in Unity. Will call @sa ReloadSofaScene.
169+ public bool ReloadScene
170+ {
171+ set
172+ {
173+ if ( value && m_impl != null )
174+ {
175+ if ( m_log )
176+ Debug . Log ( "#### SofaContext ReloadScene: " + value ) ;
177+
178+ ReloadSofaScene ( ) ;
179+ }
180+ }
181+ }
166182
167183 ////////////////////////////////////////////
168184 //////// scale conversions ///////
@@ -619,6 +635,8 @@ public void LoadSofaScene()
619635 DoCatchSofaMessages ( ) ;
620636 }
621637
638+
639+ /// Method to reconnect the current scene already loaded in SOFA with the existing Unity GameObject Hierarchy.
622640 protected void ReconnectSofaScene ( )
623641 {
624642 if ( m_sceneFileMgr == null )
@@ -647,6 +665,20 @@ protected void ReconnectSofaScene()
647665 DoCatchSofaMessages ( ) ;
648666 }
649667
668+
669+ /// Method to reload the current scene. Will clear SOFA scene and reload it internally. Then will reconnect the graph in Unity.
670+ public void ReloadSofaScene ( )
671+ {
672+ m_impl . stop ( ) ;
673+ m_impl . unload ( ) ;
674+
675+ ReconnectSofaScene ( ) ;
676+
677+ m_impl . start ( ) ;
678+ }
679+
680+
681+ /// Method to clear the current scene in SOFA and clear the graph in Unity.
650682 public void ClearSofaScene ( )
651683 {
652684 m_impl . stop ( ) ;
You can’t perform that action at this time.
0 commit comments