Custom Timeline Behaviour - GameObject can only be selected from Project Folder - not from Scene.
I created a custom Behaviour and I added a GameObject Field to it.
using UnityEngine;
using UnityEngine.Playables;
public class LocalizedDialogTimeline : PlayableAsset
{
public string dialogId;
public GameObject gameObject;
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var scriptPlayable = ScriptPlayable<LocalizedDialogTimelineBehaviour>.Create(graph);
var localizedDialogTimelineBehaviour = scriptPlayable.GetBehaviour();
localizedDialogTimelineBehaviour.dialogId = dialogId;
localizedDialogTimelineBehaviour.gameObject = gameObject;
return scriptPlayable;
}
}
using TMPro;
using UnityEngine;
using UnityEngine.Playables;
public class LocalizedDialogTimelineBehaviour : PlayableBehaviour
{
public string dialogId;
public GameObject gameObject;
}
So you should be able to enter an Id (which works like charm) and you should be able to select a GameObject. I cannot select GameObjects from the Scene. I can only select assets from my Asset folder.
I'm kinda confused why this happens. How can I select a scene GameObject in a custom timeline behaviour?
Answer by seant_unity · May 15, 2020 at 01:11 PM
An asset cannot reference a gameObject that exists in a scene. To get around this Timeline uses exposed references.
By the way - that page is missing: Sorry... that page seems to be missing!
But at least I know what to google for, now ;)
Ins$$anonymous$$d of selecting a GameObject, I now enter the name of the Gameobject. The Behaviour tries to find the GameObject in the Scene. When a GameObject with the same name was found, it will be used for further processing. It works, but it feels like a workaround. $$anonymous$$aybe you have a better idea?
Your answer
