1
Substance Integrations - Unity - Re: [BUG] Substance Plugin errors when exiting Play mode in Unity Editor
on: July 30, 2020, 04:36:08 pm
2.5.2 fixes the problem for us

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Substance.Game.Substance.Unload(graph.substance.assetpath)
to free memory , warning don't reuse any graph from taht archive anymoreSubstance.IsJobCompleted(uint)
..but when i tried it never get out of the loop... public void CopyTextures()
{
List<int> texturesIds = new List<int>();
Graph.material.GetTexturePropertyNameIDs(texturesIds);
//var orignalTextures = Graph.GetGeneratedTextures();
_textures = new List<Texture2D>();
for (int i = 0; i < texturesIds.Count; ++i)
{
Texture2D t = Graph.material.GetTexture(i) as Texture2D;
if (t != null)
{
Texture2D newTex = new Texture2D(t.width, t.height, t.format, t.mipmapCount > 0);
Graphics.CopyTexture(t, newTex);
_textures.Add(newTex);
_mat.SetTexture(texturesIds[i], newTex);
}
//Texture2D t = orignalTextures[i];
}
}
var list = Substance.Game.Substance.ListLoadedAssetPaths();
foreach (var sub in list)
{
Substance.Game.Substance.Free(sub);
}
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) object.wrapper_native_00007FFD348450C0 (intptr) [0x00009] in <437ba245d8404784b9fbab9b439ac908>:0
at Substance.Platform.NativeFunctions.cppGetPreset (intptr) [0x0003d] in D:\Git\projectname\Unity\Assets\Allegorithmic\Plugins\Substance.Platform\NativeFunctions.cs:377
at Substance.Game.SubstanceGraph.get_preset () [0x00006] in <686b229c4bb54a199af4ea1b7d9b3fc4>:0
at Substance.Game.SubstanceGraph.DuplicateInstance (Substance.Game.SubstanceGraph,string) [0x00089] in <686b229c4bb54a199af4ea1b7d9b3fc4>:0
at Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph,string) [0x00002] in <686b229c4bb54a199af4ea1b7d9b3fc4>:0
at Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph) [0x00007] in <686b229c4bb54a199af4ea1b7d9b3fc4>:0
at Substance.Game.SubstanceGraph.Duplicate () [0x00002] in <686b229c4bb54a199af4ea1b7d9b3fc4>:0
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Crash!!!
========== OUTPUTTING STACK TRACE ==================
0x00007FFD3486074D (Substance.Engine) cppShutdownSubstance
0x00007FFD3484EEAB (Substance.Engine) cppShutdownSubstance
0x0000019F6BFCEC08 (Mono JIT Code) (wrapper managed-to-native) object:wrapper_native_00007FFD348450C0 (intptr)
0x0000019F6BFCEA83 (Mono JIT Code) [D:\Git\projectname\Unity\Assets\Allegorithmic\Plugins\Substance.Platform\NativeFunctions.cs:377] Substance.Platform.NativeFunctions:cppGetPreset (intptr)
0x0000019F6BFCE61B (Mono JIT Code) Substance.Game.SubstanceGraph:get_preset ()
0x0000019F6BFCBF7B (Mono JIT Code) Substance.Game.SubstanceGraph:DuplicateInstance (Substance.Game.SubstanceGraph,string)
0x0000019F6BFC9303 (Mono JIT Code) Substance.Game.SubstanceGraph:Duplicate (Substance.Game.SubstanceGraph,string)
0x0000019F6BFC90A3 (Mono JIT Code) Substance.Game.SubstanceGraph:Duplicate (Substance.Game.SubstanceGraph)
0x0000019F6BFC8F83 (Mono JIT Code) Substance.Game.SubstanceGraph:Duplicate ()
...
<GenerateRandomMats>d__16:MoveNext ()
0x0000019F666DCB31 (Mono JIT Code) UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
0x0000019F666DCD20 (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr (object,intptr,intptr,intptr)
0x00007FFCC30DCBB0 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\mini\mini-runtime.c:2809] mono_jit_runtime_invoke
0x00007FFCC3062122 (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2921] do_runtime_invoke
0x00007FFCC306B11F (mono-2.0-bdwgc) [c:\build\output\unity-technologies\mono\mono\metadata\object.c:2968] mono_runtime_invoke
0x00007FF793B05D1E (Unity) scripting_method_invoke
0x00007FF793AFFA6D (Unity) ScriptingInvocation::Invoke
0x00007FF793AC1FDF (Unity) Coroutine::Run
0x00007FF793AD4BCC (Unity) MonoBehaviour::TryCreateAndRunCoroutine
0x00007FF793AC03AA (Unity) Coroutine::HandleIEnumerableCurrentReturnValue
0x00007FF793AC1D1F (Unity) Coroutine::ProcessCoroutineCurrent
0x00007FF793AC2113 (Unity) Coroutine::Run
0x00007FF793ABF54C (Unity) Coroutine::ContinueCoroutine
0x00007FF79317EA18 (Unity) DelayedCallManager::Update
0x00007FF7935AD15F (Unity) `InitPlayerLoopCallbacks'::`2'::UpdateScriptRunDelayedDynamicFrameRateRegistrator::Forward
0x00007FF7935963D8 (Unity) ExecutePlayerLoop
0x00007FF7935964AD (Unity) ExecutePlayerLoop
0x00007FF79359B6F4 (Unity) PlayerLoop
0x00007FF7919A799B (Unity) PlayerLoopController::UpdateScene
0x00007FF7919A58D8 (Unity) Application::TickTimer
0x00007FF7922ECF80 (Unity) MainMessageLoop
0x00007FF7922F6D1A (Unity) WinMain
0x00007FF7952895E2 (Unity) __scrt_common_main_seh
0x00007FFD48877BD4 (KERNEL32) BaseThreadInitThunk
0x00007FFD48B4CED1 (ntdll) RtlUserThreadStart
========== END OF STACKTRACE ===========
NullReferenceException: Object reference not set to an instance of an object.
at Substance.Game.SubstanceGraph.OnEnable () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.ScriptableObject.CreateInstance[T] () [0x00000] in <00000000000000000000000000000000>:0
at Substance.Game.SubstanceGraph.CreateGraphInstance (Substance.Game.Substance parent, System.UInt32 descIndex, System.UInt32 instanceIndex, System.String packageURL, System.String graphLabel, System.String prototypeName, System.String description, System.String category, System.String keywords, System.String author, System.String authorURL, System.String userTag) [0x00000] in <00000000000000000000000000000000>:0
at Substance.Game.SubstanceGraph.DuplicateInstance (Substance.Game.SubstanceGraph graph, System.String pNewGraphName) [0x00000] in <00000000000000000000000000000000>:0
at Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph graph1, System.String pNewGraphName) [0x00000] in <00000000000000000000000000000000>:0
NullReferenceException: Object reference not set to an instance of an object
Substance.Game.SubstanceGraph.GetUniqueGraphName (Substance.Game.Substance substance, System.String prototypeName) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.DuplicateInstance (Substance.Game.SubstanceGraph graph, System.String pNewGraphName) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph graph1, System.String pNewGraphName) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.Duplicate (Substance.Game.SubstanceGraph graph1) (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
Substance.Game.SubstanceGraph.Duplicate () (at <686b229c4bb54a199af4ea1b7d9b3fc4>:0)
for (int i = 0; i < nb; i++)
{
// clone substance graph
sgClone = substanceRef.Duplicate();
sgClone.SetInputFloat("$randomseed", Random.Range(0, 1 << 8));
// render substance graph
sgClone.QueueForRender();
sgClone.RenderAsync();
_RandomizeSubstancesData.Add(new SubstanceData(new Material(sgClone.material), refid));
}