File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22using UnityEngine ;
33using System . Runtime . InteropServices ;
44using System . Collections . Generic ;
5+ using System . IO ;
56
67namespace SofaUnityAPI
78{
@@ -80,7 +81,9 @@ public SofaContextAPI(bool async)
8081 }
8182
8283 CopyAssetToPersistent ( ) ;
83-
84+ #if ! UNITY_EDITOR
85+ RegenerateSofaIni ( ) ;
86+ #endif
8487 // load the sofaIni file
8588 string pathIni = Application . dataPath + "/SofaUnity/Core/Plugins/Native/x64/sofa.ini" ;
8689 string sharePath = sofaPhysicsAPI_loadSofaIni ( m_native , pathIni ) ;
@@ -110,6 +113,29 @@ public SofaContextAPI(bool async)
110113 m_sofaVersion = sofaPhysicsAPI_version ( m_native ) ;
111114 }
112115
116+
117+ /// <summary>
118+ /// simple method to regenerate sofa.ini
119+ /// </summary>
120+ private static void RegenerateSofaIni ( )
121+ {
122+ string dataPath = Application . dataPath . Replace ( "\\ " , "/" ) ;
123+ string pluginsPath = dataPath + "/Plugins/x86_64" ;
124+ string scenesPath = dataPath + "/SofaUnity/scenes/SofaScenes" ;
125+ string licensePath = dataPath + "/License/" ;
126+ string iniPath = dataPath + "/SofaUnity/Core/Plugins/Native/x64/sofa.ini" ;
127+
128+ using ( StreamWriter iniFile = new StreamWriter ( iniPath ) )
129+ {
130+ iniFile . WriteLine ( "SHARE_DIR=" + scenesPath ) ;
131+ iniFile . WriteLine ( "EXAMPLES_DIR=" + scenesPath ) ;
132+ iniFile . WriteLine ( "LICENSE_DIR=" + licensePath ) ;
133+ iniFile . WriteLine ( "BUILD_DIR=" + pluginsPath ) ;
134+ }
135+
136+ Debug . Log ( "[SofaUnity] sofa.ini regenerated at: " + iniPath ) ;
137+ }
138+
113139 /// Destructor
114140 ~ SofaContextAPI ( )
115141 {
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ public void AddPlugin(string pluginName)
127127 m_availablePlugins . Add ( new PluginInfo ( pluginName , exist ) ) ;
128128 }
129129 }
130+
130131 }
131132
132133
@@ -302,6 +303,13 @@ public PluginInfo GetPluginByName(string pluginName)
302303 return null ;
303304 }
304305
306+ public void printAvailablePlugin ( )
307+ {
308+ foreach ( PluginInfo pi in m_savedPlugins )
309+ {
310+ Debug . Log ( "Loaded plugin " + pi . Name ) ;
311+ }
312+ }
305313
306314 ////////////////////////////////////////////
307315 ////// PluginManager private API /////
Original file line number Diff line number Diff line change @@ -164,6 +164,7 @@ static void BuildForWindows(string pathToBuiltProject)
164164 outputIniFile . WriteLine ( "SHARE_DIR=" + dataBuildPath ) ;
165165 outputIniFile . WriteLine ( "EXAMPLES_DIR=" + dataBuildPath ) ;
166166 outputIniFile . WriteLine ( "LICENSE_DIR=" + rootBuildPath + "/License/" ) ;
167+ outputIniFile . WriteLine ( "BUILD_DIR=" + rootBuildPath + "/Plugins/x86_64/" ) ;
167168 Debug . Log ( "[SofaUnity - BuildForWindows] Generate: " + outputIniPath + " file." ) ;
168169 }
169170
@@ -185,6 +186,20 @@ static void BuildForWindows(string pathToBuiltProject)
185186 {
186187 Debug . LogError ( "No 'SofaScenes' folder found to copy Sofa scene related to: " + unityScenePath ) ;
187188 }
189+
190+ // Copy python3 folder if exists for python scene build
191+ string sourcePython3Path = Application . dataPath + "/SofaUnity/Core/Plugins/Native/x64/python3/" ;
192+ string destPython3Path = rootBuildPath + "/Plugins/x86_64/python3/" ;
193+
194+ if ( Directory . Exists ( sourcePython3Path ) )
195+ {
196+ DirectoryCopy ( sourcePython3Path , destPython3Path , true ) ;
197+ Debug . Log ( "[SofaUnity - BuildForWindows] Copied python3 folder to: " + destPython3Path ) ;
198+ }
199+ else
200+ {
201+ Debug . LogWarning ( "[SofaUnity - BuildForWindows] python3 folder not found at: " + sourcePython3Path + " — skipping python3 copy." ) ;
202+ }
188203 }
189204
190205
Original file line number Diff line number Diff line change @@ -431,6 +431,11 @@ void Init()
431431#if ! UNITY_ANDROID
432432 m_pluginMgr . LoadPlugins ( ) ;
433433#endif
434+ if ( m_log )
435+ {
436+ m_pluginMgr . printAvailablePlugin ( ) ;
437+ }
438+
434439 // start sofa instance
435440 if ( m_log )
436441 Debug . Log ( "## SofaContext status before start: " + m_impl . contextStatus ( ) ) ;
You can’t perform that action at this time.
0 commit comments