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

PlaybleDirector PlayOnAwake through script?

Discussion in 'Timeline' started by DGordon, Jul 10, 2017.

  1. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    How do we disable PlayOnAwake for a PlayableDirector through c# code? That field isn't actually a property in the PlayableDirector class (unless I'm really misreading things) ... I'm assuming its an exposed reference but there's no documentation as to how to get access to this. Even if its with GetReferenceValue, what is the id of the property?
     
  2. vertxxyz

    vertxxyz

    Joined:
    Oct 29, 2014
    Posts:
    109
    Code (CSharp):
    1. SerializedObject sO = new SerializedObject (playableDirector);
    2. SerializedProperty sP = sO.FindProperty ("m_InitialState");
    3. sP.enumValueIndex = 0;
    4. sO.ApplyModifiedPropertiesWithoutUndo();
    This should do the job if you're using the editor. But I too would like a better way of doing it!
     
    DGordon likes this.
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Minor oversight, we'll add it asap.
     
  4. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    648
    Thanks. The same goes for wrap modes. Basically ... anything that can be done through the visual editor should be easy (or at least documented somewhere easily found) to do through code.