Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Custom Node - Deserialization Problem

Discussion in 'Visual Scripting' started by QLQART, May 4, 2023.

  1. QLQART

    QLQART

    Joined:
    Mar 5, 2014
    Posts:
    8
    Hi. I would like to ask if anyone has ever had a problem with a custom node working in Unity Visual Scripting?
    There is no more information about it in the documentation. I seem to have done everything correctly.

    In the editor everything works as it should. When I do a build for the android platform, there is a problem with the deserialization of the custom node.

    Logcat shows a warning:
    Code (CSharp):
    1. 2023.05.04 22:26:00.122 29842 29941 Warn Unity [Deserialization] Type definition for 'WaitForFinishCoroutine' is missing.
    2. 2023.05.04 22:26:00.122 29842 29941 Warn Unity Converted 'WaitForFinishCoroutine' unit to 'Unity.VisualScripting.MissingType'. Did you delete the type's script file?
    3. 2023.05.04 22:26:00.122 29842 29941 Warn Unity Unity.VisualScripting.Serialization:HandleResult(String, fsResult, Object)
    4. 2023.05.04 22:26:00.122 29842 29941 Warn Unity Unity.VisualScripting.Serialization:DeserializeJson(fsSerializer, String, Object&, Boolean)
    5. 2023.05.04 22:26:00.122 29842 29941 Warn Unity Unity.VisualScripting.Serialization:DeserializeInto(SerializationData, Object&, Boolean)
    6. 2023.05.04 22:26:00.122 29842 29941 Warn Unity Unity.VisualScripting.LudiqScriptableObject:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize()

    Here is node code:
    Code (CSharp):
    1.  
    2. [UnitCategory("Time")]
    3. public class WaitForFinishCoroutine : WaitUnit
    4. {
    5.     [DoNotSerialize]
    6.     public ValueInput Input { get; set; }
    7.  
    8.     [DoNotSerialize]
    9.     [PortLabelHidden]
    10.     [NullMeansSelf]
    11.     public ValueInput InputMonoBehaviour { get; set; }
    12.  
    13.     protected override void Definition()
    14.     {
    15.         base.Definition();
    16.         Input = ValueInput<IEnumerator>(nameof(Input));
    17.         InputMonoBehaviour = ValueInput<MonoBehaviour>(nameof(InputMonoBehaviour), null).NullMeansSelf();
    18.     }
    19.  
    20.     protected override IEnumerator Await(Flow flow)
    21.     {
    22.         yield return flow.GetValue<MonoBehaviour>(this.InputMonoBehaviour).StartCoroutine(flow.GetValue<IEnumerator>(this.Input));
    23.         yield return this.exit;
    24.     }
    25. }
    26.  
     
  2. QLQART

    QLQART

    Joined:
    Mar 5, 2014
    Posts:
    8
    Ok. I have found the cause of this problem. It is about I2CPP and Managed Code Stripping. You need to use attribute [Preserve] before the custom class. You can find more in doc: ManagedCodeStripping
     
  3. unity_92F09588E399C315010F

    unity_92F09588E399C315010F

    Joined:
    May 7, 2023
    Posts:
    1
    My solution is write a script to make link.xml content to preserve all custom unit type