diff --git a/Core/Plugins/SofaUnityAPI/SofaContextAPI.cs b/Core/Plugins/SofaUnityAPI/SofaContextAPI.cs index 2e583923..4090fac8 100644 --- a/Core/Plugins/SofaUnityAPI/SofaContextAPI.cs +++ b/Core/Plugins/SofaUnityAPI/SofaContextAPI.cs @@ -2,6 +2,7 @@ using UnityEngine; using System.Runtime.InteropServices; using System.Collections.Generic; +using System.IO; namespace SofaUnityAPI { @@ -80,7 +81,9 @@ public SofaContextAPI(bool async) } CopyAssetToPersistent(); - +#if !UNITY_EDITOR + RegenerateSofaIni(); +#endif // load the sofaIni file string pathIni = Application.dataPath + "/SofaUnity/Core/Plugins/Native/x64/sofa.ini"; string sharePath = sofaPhysicsAPI_loadSofaIni(m_native, pathIni); @@ -110,6 +113,30 @@ public SofaContextAPI(bool async) m_sofaVersion = sofaPhysicsAPI_version(m_native); } + + /// + /// simple method to regenerate sofa.ini + /// PS: don't update the liscence path it's not needed and will make the app crash + /// + private static void RegenerateSofaIni() + { + string dataPath = Application.dataPath.Replace("\\", "/"); + string pluginsPath = dataPath + "/Plugins/x86_64"; + string scenesPath = dataPath + "/SofaUnity/scenes/SofaScenes"; + //string licensePath = dataPath + "/License/"; + string iniPath = dataPath + "/SofaUnity/Core/Plugins/Native/x64/sofa.ini"; + + using (StreamWriter iniFile = new StreamWriter(iniPath)) + { + iniFile.WriteLine("SHARE_DIR=" + scenesPath); + iniFile.WriteLine("EXAMPLES_DIR=" + scenesPath); + //iniFile.WriteLine("LICENSE_DIR=" + licensePath); + iniFile.WriteLine("BUILD_DIR=" + pluginsPath); + } + + Debug.Log("[SofaUnity] sofa.ini regenerated at: " + iniPath); + } + /// Destructor ~SofaContextAPI() { diff --git a/Core/Scripts/Editor/Config/CopyConfigPostProcessor.cs b/Core/Scripts/Editor/Config/CopyConfigPostProcessor.cs index 9f4bc104..7e9b1847 100644 --- a/Core/Scripts/Editor/Config/CopyConfigPostProcessor.cs +++ b/Core/Scripts/Editor/Config/CopyConfigPostProcessor.cs @@ -164,6 +164,7 @@ static void BuildForWindows(string pathToBuiltProject) outputIniFile.WriteLine("SHARE_DIR=" + dataBuildPath); outputIniFile.WriteLine("EXAMPLES_DIR=" + dataBuildPath); outputIniFile.WriteLine("LICENSE_DIR=" + rootBuildPath + "/License/"); + outputIniFile.WriteLine("BUILD_DIR=" + rootBuildPath + "/Plugins/x86_64/"); Debug.Log("[SofaUnity - BuildForWindows] Generate: " + outputIniPath + " file."); } @@ -185,6 +186,20 @@ static void BuildForWindows(string pathToBuiltProject) { Debug.LogError("No 'SofaScenes' folder found to copy Sofa scene related to: " + unityScenePath); } + + // Copy python3 folder if exists for python scene build + string sourcePython3Path = Application.dataPath + "/SofaUnity/Core/Plugins/Native/x64/python3/"; + string destPython3Path = rootBuildPath + "/Plugins/x86_64/python3/"; + + if (Directory.Exists(sourcePython3Path)) + { + DirectoryCopy(sourcePython3Path, destPython3Path, true); + Debug.Log("[SofaUnity - BuildForWindows] Copied python3 folder to: " + destPython3Path); + } + else + { + Debug.LogWarning("[SofaUnity - BuildForWindows] python3 folder not found at: " + sourcePython3Path + " — skipping python3 copy."); + } } diff --git a/Core/Scripts/SofaContext.cs b/Core/Scripts/SofaContext.cs index 9ff0a961..4085f15d 100644 --- a/Core/Scripts/SofaContext.cs +++ b/Core/Scripts/SofaContext.cs @@ -431,6 +431,15 @@ void Init() #if !UNITY_ANDROID m_pluginMgr.LoadPlugins(); #endif + if (m_log) + { + List pluginsPresent = m_pluginMgr.GetPluginList(); + foreach (PluginInfo pi in pluginsPresent) + { + Debug.Log("Loaded plugin " + pi.Name); + } + } + // start sofa instance if (m_log) Debug.Log("## SofaContext status before start: " + m_impl.contextStatus());