private void CreatePrefabInstance() { if (_prefabInstance == null) { DestroyPrefabInstance(); PrefabInstanceTrack track = (PrefabInstanceTrack)_trackAsset; _prefabInstance = track._prefab.LoadAndInstantiatePrefab(_prefabSpawnPoint != null ?_prefabSpawnPoint.parent : null); if (_prefabSpawnPoint != null) { if (_prefabSpawnPointIsParent) { _prefabInstance.transform.parent = _prefabSpawnPoint; _prefabInstance.transform.localPosition = Vector3.zero; _prefabInstance.transform.localRotation = Quaternion.identity; _prefabInstance.transform.localScale = Vector3.one; } else { _prefabInstance.transform.position = _prefabSpawnPoint.position; _prefabInstance.transform.rotation = _prefabSpawnPoint.rotation; _prefabInstance.transform.localScale = _prefabSpawnPoint.localScale; } } } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { PrefabInstanceTrack track = (PrefabInstanceTrack)_trackAsset; TimelineClip clip = track.GetMasterClip(); if (clip != null) { double clipStart = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start; double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration; if (_director.time >= clipStart && _director.time <= clipStart + clipDuration) { CreatePrefabInstance(); SetChildTrackBindings(_prefabInstance); } else if (_prefabInstance != null) { DestroyPrefabInstance(); ClearChildTrackBindings(); } } }
private void CreatePrefabInstance() { if (_prefabInstance == null) { PrefabInstanceTrack track = (PrefabInstanceTrack)_trackAsset; if (!track._asyncLoad || !_loadingPrefab) { DestroyPrefabInstance(); if (track._asyncLoad) { _loadingPrefab = true; //TO DO! start coroutine track._prefab.AsyncLoadAndInstantiatePrefab(new Action <GameObject>(delegate(GameObject obj) { _prefabInstance = obj; _loadingPrefab = false; SetupPrefab(); }), _prefabSpawnPoint != null ? _prefabSpawnPoint.parent : null); } else { _prefabInstance = track._prefab.LoadAndInstantiatePrefab(_prefabSpawnPoint != null ? _prefabSpawnPoint.parent : null); SetupPrefab(); } } } }