Search Unity

Null Reference in Awake() but only when timeline asset is open in the timeline window

Discussion in 'Timeline' started by arvzg, Sep 19, 2018.

  1. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    619
    Hello,

    I've got a custom track asset which has a trackbindingtype of a custom character controller class I've written.

    I'm getting a null reference exception coming up in the console when using timeline, but it seems this is only happening whenever I have the timeline asset opened in the timeline window.

    If I play the game and I make sure to either close the timeline window, or choose a different timeline, the exception doesn't get logged - but as soon as I click and open that timeline again (either through the scene OR in the project window on the asset itself) the exception comes up.

    The offending line of code is:

    Code (CSharp):
    1. _effectorBox = transform.Find("Effector Area").GetComponent<BoxCollider2D>();
    And when I put a
    Debug.Log(name) 
    right before this, the name of the object is "dummy" (which is obviously not the name of my real gameobject)

    edit:
    Removed the transform.Find call, which stops it from erroring on that line, but is now erroring on lines below that. What is this dummy thing even doing? It looks like it's created a clone of my object, but without any of its children or components, so it runs Awake, but doesn't have anything it needs?
     
    Last edited: Sep 19, 2018