Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

VisualEffect Component "Unregistered" when building for iOS, crashes build

Discussion in 'World Building' started by michaelthewanderer, Jun 7, 2022.

  1. michaelthewanderer

    michaelthewanderer

    Joined:
    Jul 15, 2018
    Posts:
    12
    I am adding a VisualEffect component to a game object via script:

    Code (CSharp):
    1.     public void GenerateMatter()
    2.     {
    3.  
    4.         VisualEffect matter = gameObject.AddComponent<VisualEffect>();
    5.  
    6.         matter.visualEffectAsset = Resources.Load("fx", typeof(VisualEffectAsset)) as VisualEffectAsset;
    7.  
    8.         matter.SetMesh("Spacetime", renderMesh);
    9.      
    10.     }
    This code works and runs perfectly in the editor.

    However when I build the project for iOS and run it, the build crashes and I see the following message in Xcode:

    Code (CSharp):
    1. Can't add component because '[UNREGISTERED]' is not derived from Component.
    2. UnityEngine.GameObject:AddComponent()
    3. Manifold:GenerateMatter()

    I am certain that the AddComponent call in GenerateMatter() is what is causing the crash, and the VisualEffect is the only AddComponent call in that function (I commented this line out and built it, and the build ran successfully).

    Is there something I should be aware of with the VisualEffect Component type? I confirmed from Unity's documentation that Visual Effect inherits from Behavior -> Component.

    Thank You
     
  2. michaelthewanderer

    michaelthewanderer

    Joined:
    Jul 15, 2018
    Posts:
    12