Author Topic: Scripting: Options Menu input type?  (Read 714 times)

Hi there, for a current project I'm setting up some substances dynamically using the GetInputProperties(); function.
Almost all input types are working as expected however I have trouble finding out which input type the option menus take.
The menus are returned as enums however using for example the SetInputInt(); function and calling the index returns an invalid input parameter error.

I thought I might have to use SetInputString(); and then specify the name and option, however this leads to an instant Unity Crash.
Here's the crash log:
Code: [Select]
(Filename: Assets/Allegorithmic/Plugins/Substance.Platform/NativeFunctions.cs Line: 810)

Stacktrace:

  at <unknown> <0xffffffff>
  at (wrapper managed-to-native) object.wrapper_native_00007FFDF8A85460 (intptr,string,string) [0x0001f] in <eae584ce26bc40229c1b1aa476bfa589>:0
  at Substance.Platform.NativeFunctions.cppSetInput_String (intptr,string,string) [0x00034] in D:\CMGT\Minor\Unity\Minor Project\Assets\Allegorithmic\Plugins\Substance.Platform\NativeFunctions.cs:810
  at Substance.Game.SubstanceGraph.SetInputString (string,string) [0x00008] in <d61fbcfb9b2e49f89a7821e6adc37669>:0
  at substance_procedural.testButtonClick () [0x00000] in D:\CMGT\Minor\Unity\Minor Project\Assets\Scripts\Substances\substance_procedural.cs:70
  at UnityEngine.Events.InvokableCall.Invoke () [0x00016] in <10564ed154d647e194bef4aef8878649>:0
  at UnityEngine.Events.UnityEvent.Invoke () [0x00023] in <10564ed154d647e194bef4aef8878649>:0
  at UnityEngine.UI.Button.Press () [0x0001c] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Button.cs:68
  at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData) [0x00009] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\UI\Core\Button.cs:110
  at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler,UnityEngine.EventSystems.BaseEventData) [0x00000] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:50
  at UnityEngine.EventSystems.ExecuteEvents.Execute<T_REF> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<T_REF>) [0x0006c] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\ExecuteEvents.cs:262
  at UnityEngine.EventSystems.StandaloneInputModule.ReleaseMouse (UnityEngine.EventSystems.PointerEventData,UnityEngine.GameObject) [0x0002f] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:187
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessMousePress (UnityEngine.EventSystems.PointerInputModule/MouseButtonEventData) [0x0012c] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:642
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent (int) [0x0002e] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:548
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessMouseEvent () [0x00000] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:528
  at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00032] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\InputModules\StandaloneInputModule.cs:282
  at UnityEngine.EventSystems.EventSystem.Update () [0x000b7] in C:\Program Files\Unity\Hub\Editor\2020.3.1f1\Editor\Data\Resources\PackageManager\BuiltInPackages\com.unity.ugui\Runtime\EventSystem\EventSystem.cs:385
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00020] in <eae584ce26bc40229c1b1aa476bfa589>: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.
=================================================================

Received signal SIGSEGV
Stack trace:
0x00007ffdf8a84085 (Substance.Engine)
0x00007ffdf8a94f7e (Substance.Engine) cppShutdownSubstance
0x00007ffdf8a8345e (Substance.Engine)
0x000002196692a3af (Mono JIT Code) (wrapper managed-to-native) object:wrapper_native_00007FFDF8A85460 (intptr,string,string)
0x000002196692a2d7 (Mono JIT Code) [NativeFunctions.cs:810] Substance.Platform.NativeFunctions:cppSetInput_String (intptr,string,string)
0x000002196692a1c3 (Mono JIT Code) Substance.Game.SubstanceGraph:SetInputString (string,string)
0x000002196692a10b (Mono JIT Code) [substance_procedural.cs:71] substance_procedural:testButtonClick ()
0x00000218f9eb3ae9 (Mono JIT Code) UnityEngine.Events.InvokableCall:Invoke ()
0x00000218f9eb342b (Mono JIT Code) UnityEngine.Events.UnityEvent:Invoke ()
0x000002196690d1e3 (Mono JIT Code) [Button.cs:69] UnityEngine.UI.Button:Press ()
0x000002196690d123 (Mono JIT Code) [Button.cs:111] UnityEngine.UI.Button:OnPointerClick (UnityEngine.EventSystems.PointerEventData)
0x000002196690d0c9 (Mono JIT Code) [ExecuteEvents.cs:51] UnityEngine.EventSystems.ExecuteEvents:Execute (UnityEngine.EventSystems.IPointerClickHandler,UnityEngine.EventSystems.BaseEventData)
0x0000021966906102 (Mono JIT Code) [ExecuteEvents.cs:262] UnityEngine.EventSystems.ExecuteEvents:Execute<T_REF> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<T_REF>)
0x000002196690cdab (Mono JIT Code) [StandaloneInputModule.cs:189] UnityEngine.EventSystems.StandaloneInputModule:ReleaseMouse (UnityEngine.EventSystems.PointerEventData,UnityEngine.GameObject)
0x0000021a2d9ce933 (Mono JIT Code) [StandaloneInputModule.cs:644] UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress (UnityEngine.EventSystems.PointerInputModule/MouseButtonEventData)
0x0000021a2d9c8c83 (Mono JIT Code) [StandaloneInputModule.cs:549] UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent (int)
0x0000021a2d9c8b4b (Mono JIT Code) [StandaloneInputModule.cs:529] UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent ()
0x0000021a2d9c8613 (Mono JIT Code) [StandaloneInputModule.cs:284] UnityEngine.EventSystems.StandaloneInputModule:Process ()
0x00000218fa4132df (Mono JIT Code) [EventSystem.cs:388] UnityEngine.EventSystems.EventSystem:Update ()
0x00000218fa5edaf0 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffdf355e480 (mono-2.0-bdwgc) [mini-runtime.c:2812] mono_jit_runtime_invoke
0x00007ffdf34e2902 (mono-2.0-bdwgc) [object.c:2921] do_runtime_invoke
0x00007ffdf34eb95f (mono-2.0-bdwgc) [object.c:2968] mono_runtime_invoke
0x00007ff7ad9aaa34 (Unity) scripting_method_invoke
0x00007ff7ad9a33b5 (Unity) ScriptingInvocation::Invoke
0x00007ff7ad966a44 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff7ad966b4c (Unity) MonoBehaviour::CallUpdateMethod
0x00007ff7ace47ad8 (Unity) BaseBehaviourManager::CommonUpdate<BehaviourManager>
0x00007ff7ace51a2a (Unity) BehaviourManager::Update
0x00007ff7ad2b547a (Unity) `InitPlayerLoopCallbacks'::`2'::UpdateScriptRunBehaviourUpdateRegistrator::Forward
0x00007ff7ad29676c (Unity) ExecutePlayerLoop
0x00007ff7ad296843 (Unity) ExecutePlayerLoop
0x00007ff7ad29d6c9 (Unity) PlayerLoop
0x00007ff7ae6ad991 (Unity) PlayerLoopController::UpdateScene
0x00007ff7ae6ab626 (Unity) Application::TickTimer
0x00007ff7af013bb1 (Unity) MainMessageLoop
0x00007ff7af017bf1 (Unity) WinMain
0x00007ff7b0e8e0d6 (Unity) __scrt_common_main_seh
0x00007ffe4e3e7034 (KERNEL32) BaseThreadInitThunk
0x00007ffe4fb82651 (ntdll) RtlUserThreadStart

Can anyone tell me what function to use to input options from an option/dropdown menu?

Best,
Chloe

Edit:
I found out that it is indeed an int not a string. However there seems to be no way of knowing which dropdown option corresponds to what integer value which makes it basically impossible to populate dynamically.
Last Edit: April 11, 2021, 03:43:09 pm

TaliZorah's asked the same question in another forum and we replied to her in that forum. Here is our developer's answer to the question for users who may want to know.

"The only way I was able to reproduce the problem was to install the script twice in the gameObject. Hopefully you used the Duplicate function reset.

So, instead of duplicating a graph, save the preset:
string initialPreset = substance.preset;
and when it's time to reset the graph, do:
substance.preset = initialPreset;
substance.QueueForRender();
Substance.Game.Substance.RenderSubstancesAsync();"