Search Unity

Start() being called but not Update() on "imported" GameObjects

Discussion in 'Scripting' started by TJaenichen, Jul 22, 2020.

  1. TJaenichen

    TJaenichen

    Joined:
    Oct 12, 2014
    Posts:
    29
    Basically I load assetbundles and compiled dlls at runtime. This works pretty well so far and I can instantiate prefabs and load them into my scene.

    The components are there and I can read/write fields/properties like with any other gameobject. Even Start() is being called, however Update() is not.

    It looks like the UnityEngine doesn't have it registered somewhere it stores the list of Objects to Update().

    Any ideas?
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    1. You misspelled Update() or otherwise have the wrong method signature. One common mistake is not capitalizing the "U"
    2. Your GameObject is getting deactivated or the MonoBehaviour is getting disabled.
     
    lordofduct likes this.
  3. TJaenichen

    TJaenichen

    Joined:
    Oct 12, 2014
    Posts:
    29
    Tried it with multiple scripts, also with the generated void Update() scripts, not a typo

    The object is definitely active. Also checked with the debugger and it's both activeself and inhierarchy.
    Other scripts that I pump through the same pipeline and that don't rely on the Update() call work. So I can use it for fire off events from button clicks, for example.
     
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    How are you loading the prefabs into the scene? Are you just Instantiating them or are you doing additive scene loading?
     
  5. adehm

    adehm

    Joined:
    May 3, 2017
    Posts:
    369
    Sounds impossible. Create a script that you can get the Update to work for in where you reference all the things you want to call then make the things you want to call public void Update and call them inside the new script; referencedObject.Update().
     
  6. TJaenichen

    TJaenichen

    Joined:
    Oct 12, 2014
    Posts:
    29
    > Are you just Instantiating them or are you doing additive scene loading?

    All in the same scene. And just to be sure, it's instantiated after the gameobject is loaded from a prefab inside an assetbundle.
     
  7. TJaenichen

    TJaenichen

    Joined:
    Oct 12, 2014
    Posts:
    29
    Ok, found something else out... This only happens under if they are children of some objects (all UI).

    Those objects only have a RectTransform and are definitely enabled
     
  8. TJaenichen

    TJaenichen

    Joined:
    Oct 12, 2014
    Posts:
    29
    Found it, it was a bug somewhere else that seemed unrelated at first
     
    PraetorBlue likes this.