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.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

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:
    10
    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:
    10