void timelineAction()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (go == null || timeline == null || timelineAsset == null)
            {
                return;
            }

            try{
                if (trackIndex.IsNone && trackName.IsNone)
                {
                    _playableBinding = timelineAsset.outputs.FirstOrDefault();
                }
                else
                {
                    if (!trackIndex.IsNone && (trackIndex.Value > 0 || trackIndex.Value < timelineAsset.outputs.Count()))
                    {
                        _playableBinding = timelineAsset.outputs.ElementAt <PlayableBinding> (trackIndex.Value);
                    }

                    if (!trackName.IsNone && !string.IsNullOrEmpty(trackName.Value))
                    {
                        _playableBinding = timelineAsset.outputs.First(c => c.streamName == trackName.Value);
                    }
                }
            }catch (Exception e) {
                Fsm.Event(failureEvent);
                return;
            }

            timeline.SetGenericBinding(_playableBinding.sourceObject, Fsm.GetOwnerDefaultTarget(bindingObject));
        }
Exemplo n.º 2
0
 GUIContent GetContentForOutput(PlayableBinding binding, UnityEngine.Object source)
 {
     m_BindingContent.text    = binding.streamName;
     m_BindingContent.tooltip = (source == null) ? Styles.NoBindingsContent.text : string.Empty;
     m_BindingContent.image   = AssetPreview.GetMiniTypeThumbnail(binding.outputTargetType) ?? m_DefaultScriptContentTexture;
     return(m_BindingContent);
 }
Exemplo n.º 3
0
    public void SetCinemachineTrackData(PlayableBinding binding, PlayableDirector director)
    {
        CinemachineBrain brain = CameraControll.Instance.gameObject.GetComponent <CinemachineBrain>();

        if (brain == null)
        {
            brain = CameraControll.Instance.gameObject.AddComponent <CinemachineBrain>();
        }
        director.SetGenericBinding(binding.sourceObject, brain);
        foreach (TimelineClip clip in (binding.sourceObject as TrackAsset).GetClips())
        {
            var shot = clip.asset as MYCinemachineShot;
            if (shot)
            {
                //var mainVm = brain.transform.FindChild("VM").GetComponent<CinemachineVirtualCamera>();
                //shot.VirtualCamera = new ExposedReference<CinemachineVirtualCameraBase>();
                //director.SetReferenceValue(shot.VirtualCamera.exposedName, mainVm);
                var vmGo = director.gameObject.transform.Find(shot.VmPath);
                if (vmGo)
                {
                    shot.VirtualCamera = vmGo.GetComponent <CinemachineVirtualCameraBase>();
                }
            }
        }
    }
Exemplo n.º 4
0
 private void BindingInspector(SerializedProperty bindingProperty, PlayableBinding binding)
 {
     if (!(binding.sourceObject == null))
     {
         UnityEngine.Object objectReferenceValue = bindingProperty.objectReferenceValue;
         if (binding.streamType == DataStreamType.Audio)
         {
             this.m_AudioContent.text    = binding.streamName;
             this.m_AudioContent.tooltip = ((!(objectReferenceValue == null)) ? string.Empty : DirectorEditor.Styles.NoBindingsContent.text);
             DirectorEditor.PropertyFieldAsObject(bindingProperty, this.m_AudioContent, typeof(AudioSource), false, false);
         }
         else if (binding.streamType == DataStreamType.Animation)
         {
             this.m_AnimatorContent.text    = binding.streamName;
             this.m_AnimatorContent.tooltip = ((!(objectReferenceValue is GameObject)) ? string.Empty : DirectorEditor.Styles.NoBindingsContent.text);
             DirectorEditor.PropertyFieldAsObject(bindingProperty, this.m_AnimatorContent, typeof(Animator), true, true);
         }
         else if (binding.streamType == DataStreamType.None)
         {
             this.m_ScriptContent.text    = binding.streamName;
             this.m_ScriptContent.tooltip = ((!(objectReferenceValue == null)) ? string.Empty : DirectorEditor.Styles.NoBindingsContent.text);
             this.m_ScriptContent.image   = (AssetPreview.GetMiniTypeThumbnail(binding.sourceBindingType) ?? this.m_DefaultScriptContentTexture);
             if (binding.sourceBindingType != null && typeof(UnityEngine.Object).IsAssignableFrom(binding.sourceBindingType))
             {
                 DirectorEditor.PropertyFieldAsObject(bindingProperty, this.m_ScriptContent, binding.sourceBindingType, true, false);
             }
         }
     }
 }
Exemplo n.º 5
0
        public static Component AddRequiredComponent(GameObject go, TrackAsset asset)
        {
            Component result;

            if (go == null || asset == null)
            {
                result = null;
            }
            else
            {
                IEnumerable <PlayableBinding> outputs = asset.get_outputs();
                if (!outputs.Any <PlayableBinding>())
                {
                    result = null;
                }
                else
                {
                    PlayableBinding playableBinding = outputs.First <PlayableBinding>();
                    if (playableBinding.get_streamType() == null)
                    {
                        Animator animator = go.GetComponent <Animator>();
                        if (animator == null)
                        {
                            animator = Undo.AddComponent <Animator>(go);
                            animator.set_applyRootMotion(true);
                        }
                        result = animator;
                    }
                    else if (playableBinding.get_streamType() == 1)
                    {
                        AudioSource audioSource = go.GetComponent <AudioSource>();
                        if (audioSource == null)
                        {
                            audioSource = Undo.AddComponent <AudioSource>(go);
                        }
                        result = audioSource;
                    }
                    else if (playableBinding.get_streamType() == 3 && typeof(Component).IsAssignableFrom(playableBinding.get_sourceBindingType()))
                    {
                        Component component = go.GetComponent(playableBinding.get_sourceBindingType());
                        if (component == null)
                        {
                            component = Undo.AddComponent(go, playableBinding.get_sourceBindingType());
                        }
                        result = component;
                    }
                    else
                    {
                        result = null;
                    }
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        private void BindingInspector(SerializedProperty bindingProperty, PlayableBinding binding)
        {
            if (binding.sourceObject == null || binding.outputTargetType == null || !typeof(UnityEngine.Object).IsAssignableFrom(binding.outputTargetType))
            {
                return;
            }

            var source = bindingProperty.objectReferenceValue;

            PropertyFieldAsObject(bindingProperty,
                                  GetContentForOutput(binding, source),
                                  binding.outputTargetType
                                  );
        }
Exemplo n.º 7
0
    private void SetupAndPlay(TimelineAsset playableAsset)
    {
        var bindings   = playableAsset.outputs;
        var enumerator = bindings.GetEnumerator();

        while (enumerator.MoveNext())
        {
            PlayableBinding binding = enumerator.Current;
            switch (binding.streamName)
            {
            case "Signal":
                director.SetGenericBinding(binding.sourceObject, GetComponent <SignalReceiver>()); break;

            case "Camera1":
            case "Camera1_Active":
                cameraOne.gameObject.SetActive(true);
                director.SetGenericBinding(binding.sourceObject, cameraOne.GetComponent <Animator>()); break;

            case "Camera2":
            case "Camera2_Active":
                cameraTwo.gameObject.SetActive(true);
                director.SetGenericBinding(binding.sourceObject, cameraTwo.GetComponent <Animator>()); break;

            case "Target":
                director.SetGenericBinding(binding.sourceObject, cameraFollower.GetComponent <Animator>()); break;

            case "Batter":
                director.SetGenericBinding(binding.sourceObject, Batter.animator);
                break;

            case "Catcher":
                director.SetGenericBinding(binding.sourceObject, Catcher.animator);
                break;

            case "Umpire":
                director.SetGenericBinding(binding.sourceObject, GetUmpire().animator);
                break;

            case "Pitcher":
                director.SetGenericBinding(binding.sourceObject, Pitcher.animator);
                break;

            case "Ball":
                director.SetGenericBinding(binding.sourceObject, Ball.GetComponent <Animator>());
                break;
            }
        }

        director.Play(playableAsset, DirectorWrapMode.Loop);
    }
Exemplo n.º 8
0
        private static Type GetRequiredBindingType(PlayableBinding binding)
        {
            Type result = binding.get_sourceBindingType();

            if (binding.get_streamType() == null)
            {
                result = typeof(Animator);
            }
            else if (binding.get_streamType() == 1)
            {
                result = typeof(AudioSource);
            }
            return(result);
        }
Exemplo n.º 9
0
 private void SynchSceneBindings()
 {
     if (base.targets.Length <= 1)
     {
         PlayableDirector playableDirector = (PlayableDirector)base.target;
         PlayableAsset    playableAsset    = this.m_PlayableAsset.objectReferenceValue as PlayableAsset;
         this.m_BindingPropertiesCache.Clear();
         this.m_SynchedPlayableBindings = null;
         if (!(playableAsset == null))
         {
             IEnumerable <PlayableBinding> outputs = playableAsset.outputs;
             this.m_SynchedPlayableBindings = outputs.ToArray <PlayableBinding>();
             PlayableBinding[] synchedPlayableBindings = this.m_SynchedPlayableBindings;
             for (int i = 0; i < synchedPlayableBindings.Length; i++)
             {
                 PlayableBinding playableBinding = synchedPlayableBindings[i];
                 if (!playableDirector.HasGenericBinding(playableBinding.sourceObject))
                 {
                     playableDirector.SetGenericBinding(playableBinding.sourceObject, null);
                 }
             }
             base.serializedObject.Update();
             SerializedProperty[] array = new SerializedProperty[this.m_SceneBindings.arraySize];
             for (int j = 0; j < this.m_SceneBindings.arraySize; j++)
             {
                 array[j] = this.m_SceneBindings.GetArrayElementAtIndex(j);
             }
             PlayableBinding[] synchedPlayableBindings2 = this.m_SynchedPlayableBindings;
             for (int k = 0; k < synchedPlayableBindings2.Length; k++)
             {
                 PlayableBinding      binding = synchedPlayableBindings2[k];
                 SerializedProperty[] array2  = array;
                 for (int l = 0; l < array2.Length; l++)
                 {
                     SerializedProperty serializedProperty = array2[l];
                     if (serializedProperty.FindPropertyRelative("key").objectReferenceValue == binding.sourceObject)
                     {
                         this.m_BindingPropertiesCache.Add(new DirectorEditor.BindingPropertyPair
                         {
                             binding  = binding,
                             property = serializedProperty.FindPropertyRelative("value")
                         });
                         break;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 10
0
 private void SetTileLine()
 {
     this.menuPlayableDirector.set_playableAsset(!this.isUploader ? this.menuTimeLine1 : this.menuTimeLine);
     for (int i = 0; i < this.lstTimeLlineInfos.Count; ++i)
     {
         PlayableBinding playableBinding = this.menuPlayableDirector.get_playableAsset().get_outputs().First <PlayableBinding>((Func <PlayableBinding, bool>)(c => ((PlayableBinding) ref c).get_streamName() == this.lstTimeLlineInfos[i].trackName));
         if (this.lstTimeLlineInfos[i].kind == TitleScene.TimeLineKind.animation)
         {
             this.menuPlayableDirector.SetGenericBinding(((PlayableBinding) ref playableBinding).get_sourceObject(), (Object)this.lstTimeLlineInfos[i].animator);
         }
         else if (this.lstTimeLlineInfos[i].kind == TitleScene.TimeLineKind.activeObject)
         {
             this.menuPlayableDirector.SetGenericBinding(((PlayableBinding) ref playableBinding).get_sourceObject(), (Object)this.lstTimeLlineInfos[i].activeObject);
         }
     }
 }
Exemplo n.º 11
0
        static void ObjectBindingField(Rect position, Object obj, PlayableBinding binding)
        {
            bool allowScene =
                typeof(GameObject).IsAssignableFrom(binding.outputTargetType) ||
                typeof(Component).IsAssignableFrom(binding.outputTargetType);

            EditorGUI.BeginChangeCheck();
            // FocusType.Passive so it never gets focused when pressing tab
            int controlId = GUIUtility.GetControlID("s_ObjectFieldHash".GetHashCode(), FocusType.Passive, position);
            var newObject = EditorGUI.DoObjectField(EditorGUI.IndentedRect(position), EditorGUI.IndentedRect(position), controlId, obj, binding.outputTargetType, null, null, allowScene, EditorStyles.objectField);

            if (EditorGUI.EndChangeCheck())
            {
                BindingUtility.Bind(TimelineEditor.inspectedDirector, binding.sourceObject as TrackAsset, newObject);
            }
        }
    public static int constructor(IntPtr l)
    {
        int result;

        try
        {
            PlayableBinding playableBinding = default(PlayableBinding);
            LuaObject.pushValue(l, true);
            LuaObject.pushValue(l, playableBinding);
            result = 2;
        }
        catch (Exception e)
        {
            result = LuaObject.error(l, e);
        }
        return(result);
    }
Exemplo n.º 13
0
        static void ObjectBindingField(Rect position, Object obj, PlayableBinding binding)
        {
            bool allowScene =
                typeof(GameObject).IsAssignableFrom(binding.outputTargetType) ||
                typeof(Component).IsAssignableFrom(binding.outputTargetType);

            using (var check = new EditorGUI.ChangeCheckScope())
            {
                // FocusType.Passive so it never gets focused when pressing tab
                int controlId = GUIUtility.GetControlID("s_ObjectFieldHash".GetHashCode(), FocusType.Passive, position);
                var newObject = UnityEditorInternals.DoObjectField(EditorGUI.IndentedRect(position), obj, binding.outputTargetType, controlId, allowScene);
                if (check.changed)
                {
                    BindingUtility.Bind(TimelineEditor.inspectedDirector, binding.sourceObject as TrackAsset, newObject);
                }
            }
        }
Exemplo n.º 14
0
    private void CreateOneTrack(PlayableBinding pb)
    {
        TrackAsset track = pb.sourceObject as TrackAsset;
        //实例化
        GameObject obj = GameObject.Instantiate(this._templete.gameObject);
        obj.name = track.name;
        obj.transform.SetParent(this._scroll.content.transform, false);
        obj.SetActive(true);
        string uid = Utils.GenerateUId();
        PlayableBindingItem item = obj.GetComponent<PlayableBindingItem>();
        item.SetDetails(track, uid, this._director);
        _Tracks.Add(uid, item);

        foreach (string id in item._Clips.Keys)
        {
            this._AllClips.Add(id, item._Clips[id]);
        }
    }
Exemplo n.º 15
0
 private void ProcessBind(PlayableBinding output, string tag, DynamicDialogueBinder.DialogueBind bind)
 {
     if (output.outputTargetType == typeof(Animator))
     {
         director.SetGenericBinding(output.sourceObject, bind.DialogueBubbleAnimator);
     }
     else if (output.outputTargetType == typeof(GameObject))
     {
         director.SetGenericBinding(output.sourceObject, bind.DialogueBubbleObject);
     }
     else if (output.outputTargetType == typeof(TMPro.TMP_Text))
     {
         director.SetGenericBinding(output.sourceObject, bind.DialogueBubbleText);
     }
     else
     {
         Debug.LogError($"Unsupported binding {output.outputTargetType} : {tag}");
     }
 }
Exemplo n.º 16
0
    // Use this for initialization
    void Start()
    {
        PlayableDirector director = gameObject.AddComponent <PlayableDirector>();

        //director.wrapMode = DirectorWrapMode.Loop;
        director.initialTime    = 0.0;
        director.timeUpdateMode = DirectorUpdateMode.GameTime;

        TimelineAsset timeline = (TimelineAsset)Resources.Load("MyTimeline");

        IEnumerator <PlayableBinding> outputs = timeline.outputs.GetEnumerator();

        PlayableBinding binding = outputs.Current;

        TrackAsset track = binding.sourceObject as TrackAsset;

        director.SetGenericBinding(track, gameObject);
        director.Play(timeline);
        director.time = 42.0f;
    }
 public static void SetSceneGameObject(PlayableDirector director, TrackAsset asset, GameObject go)
 {
     if (!(director == null) && !(asset == null))
     {
         asset = TimelineUtility.GetSceneReferenceTrack(asset);
         IEnumerable <PlayableBinding> outputs = asset.get_outputs();
         if (outputs.Count <PlayableBinding>() != 0)
         {
             PlayableBinding playableBinding = outputs.First <PlayableBinding>();
             if (playableBinding.get_streamType() == null || playableBinding.get_sourceBindingType() == typeof(GameObject))
             {
                 TimelineHelpers.AddRequiredComponent(go, asset);
                 TimelineUtility.SetBindingInDirector(director, asset, go);
             }
             else
             {
                 TimelineUtility.SetBindingInDirector(director, asset, TimelineHelpers.AddRequiredComponent(go, asset));
             }
         }
     }
 }
Exemplo n.º 18
0
        private void BindingInspector(SerializedProperty bindingProperty, PlayableBinding binding)
        {
            if (binding.sourceObject == null)
            {
                return;
            }

            var source = bindingProperty.objectReferenceValue;

            if (binding.streamType == DataStreamType.Audio)
            {
                m_AudioContent.text    = binding.streamName;
                m_AudioContent.tooltip = source == null ? Styles.NoBindingsContent.text : string.Empty;
                PropertyFieldAsObject(bindingProperty, m_AudioContent, typeof(AudioSource), true);
            }
            else if (binding.streamType == DataStreamType.Animation)
            {
                m_AnimatorContent.text    = binding.streamName;
                m_AnimatorContent.tooltip = source is GameObject ? Styles.NoBindingsContent.text : string.Empty;
                PropertyFieldAsObject(bindingProperty, m_AnimatorContent, typeof(Animator), true, true);
            }
            if (binding.streamType == DataStreamType.Texture)
            {
                m_VideoContent.text    = binding.streamName;
                m_VideoContent.tooltip = source == null ? Styles.NoBindingsContent.text : string.Empty;
                PropertyFieldAsObject(bindingProperty, m_VideoContent, typeof(RenderTexture), false);
            }
            else if (binding.streamType == DataStreamType.None)
            {
                m_ScriptContent.text    = binding.streamName;
                m_ScriptContent.tooltip = source == null ? Styles.NoBindingsContent.text : string.Empty;
                m_ScriptContent.image   = AssetPreview.GetMiniTypeThumbnail(binding.sourceBindingType) ?? m_DefaultScriptContentTexture;

                if (binding.sourceBindingType != null && typeof(UnityEngine.Object).IsAssignableFrom(binding.sourceBindingType))
                {
                    PropertyFieldAsObject(bindingProperty, m_ScriptContent, binding.sourceBindingType, true);
                }
            }
        }
Exemplo n.º 19
0
 private static void SetPlayableOutputParameters <T>(T output, Playable playable, int port, PlayableBinding binding) where T : struct, IPlayableOutput
 {
     output.SetReferenceObject(binding.sourceObject);
     output.SetSourcePlayable(playable);
     output.SetSourceInputPort(port);
 }
    IEnumerator LoadActorPrefabCoroutine(GameObject oldObj, PlayableDirector playableDirector, PlayableBinding playableBinding, Transform parent, uint rid, string gameObjectName)
    {
        if (mModelIds == null)
        {
            yield break;
        }
        uint      modelId   = mModelIds[(int)rid - 1];
        ModelInfo modelInfo = ModelHelper.GetModel(modelId);

        if (modelInfo == null)
        {
            GameDebug.LogError("Load actor prefab error, can not find model:" + modelId);
            yield break;
        }
        string prefabPath = modelInfo.Model;

        SGameEngine.PrefabResource pr = new SGameEngine.PrefabResource();
        yield return(SGameEngine.ResourceLoader.Instance.StartCoroutine(SGameEngine.ResourceLoader.Instance.load_prefab(string.Format("Assets/Res/{0}.prefab", prefabPath), pr)));

        GameObject obj = pr.obj_;

        if (obj == null)
        {
            GameDebug.LogError("Load actor prefab " + prefabPath + " error, can not load prefab!");
            yield break;
        }

        obj.name = gameObjectName;

        OnActorPrefabLoadSuccess(oldObj, obj, playableDirector, playableBinding, parent, modelInfo);
    }
Exemplo n.º 21
0
    public void Bind()
    {
        PlayableBinding binding = director.playableAsset.outputs.First(c => c.streamName == targetTrackName);

        director.SetGenericBinding(binding.sourceObject, cloneObject);
    }
Exemplo n.º 22
0
        /// <summary>
        /// 获得当前streamName的绑定
        /// </summary>
        /// <param name="director"></param>
        /// <param name="streamName"></param>
        /// <param name="binding"></param>
        /// <returns>当前director的playableasset的output中是否有当前streamName</returns>
        public static bool GetPlayableBindingByStreamName(PlayableDirector director, string streamName, out PlayableBinding binding)
        {
            bool hasName = false;

            binding = default(PlayableBinding);

            foreach (PlayableBinding b in director.playableAsset.outputs)
            {
                if (b.streamName == streamName)
                {
                    binding = b;
                    hasName = true;
                    break;
                }
            }

            return(hasName);
        }
Exemplo n.º 23
0
        protected override JSONObject ToJSON(WXHierarchyContext context)
        {
            JSONObject json        = new JSONObject(JSONObject.Type.OBJECT);
            JSONObject data        = new JSONObject(JSONObject.Type.OBJECT);
            JSONObject bindingsArr = new JSONObject(JSONObject.Type.OBJECT);

            json.AddField("type", getTypeName());
            json.AddField("data", data);
            int timeUpdateMode;

            UpdateMode.TryGetValue(playableDirector.timeUpdateMode, out timeUpdateMode);
            data.AddField("timeUpdateMode", timeUpdateMode);
            data.AddField("playOnAwake", playableDirector.playOnAwake); // 貌似unity怎么搞playOnAwake都是false
            int wrapMode;

            WrapMode.TryGetValue(playableDirector.extrapolationMode, out wrapMode);
            data.AddField("wrapMode", wrapMode);
            data.AddField("initialTime", (float)playableDirector.initialTime);
            data.AddField("duration", (float)playableDirector.duration);
            data.AddField("sceneBindings", bindingsArr);

            TimelineAsset timelineAsset = (TimelineAsset)playableDirector.playableAsset;

            if ((UnityEngine.Object)timelineAsset != (UnityEngine.Object)null && timelineAsset.outputTrackCount > 0) // 有output
            {
                WXTimelineAssets converter         = new WXTimelineAssets(timelineAsset, gameObject);
                string           timelineAssetPath = converter.Export(context.preset);
                if (timelineAssetPath != null && timelineAssetPath != "")
                {
                    data.AddField("playableAsset", timelineAssetPath);
                    context.AddResource(timelineAssetPath);
                    string playableAssetPath = AssetDatabase.GetAssetPath(timelineAsset); // timeline资源路径
                    IEnumerator <PlayableBinding> outputsEnumerator = timelineAsset.outputs.GetEnumerator();
                    List <TrackAsset>             outputTracks      = timelineAsset.GetOutputTracks().ToList();;
                    int num = 0;
                    while (outputsEnumerator.MoveNext()) // 遍历bindings
                    {
                        JSONObject      bindingData  = new JSONObject(JSONObject.Type.OBJECT);
                        PlayableBinding binding      = (PlayableBinding)outputsEnumerator.Current;
                        var             sourceObject = playableDirector.GetGenericBinding(binding.sourceObject); // 获取binding里sourceobject对应的entity
                        string          componentId  = "";
                        string          localId      = WXTimelineAssets.GetTrackLocalIdByInstanceID(playableAssetPath, outputTracks[num].GetInstanceID());
                        if ((UnityEngine.Object)sourceObject != (UnityEngine.Object)null)
                        {
                            if (binding.sourceObject.GetType() == typeof(ActivationTrack)) // active track绑定的是entity
                            {
                                Transform transform = (sourceObject as GameObject).GetComponent(typeof(Transform)) as Transform;
                                componentId = context.AddComponentInProperty(
                                    new WXTransform3DComponent(transform),
                                    transform
                                    );
                            }
                            else if (binding.sourceObject.GetType() == typeof(AudioTrack)) // audio track 绑定AudioSource
                            {
                                componentId = context.AddComponentInProperty(
                                    new WXAudioSource((AudioSource)sourceObject, (GameObject)(sourceObject as AudioSource).gameObject),
                                    (AudioSource)sourceObject
                                    );
                            }
                            else if (binding.sourceObject.GetType() == typeof(AnimationTrack)) // animation track 绑定Animator
                            {
                                Animator animator;
                                if (sourceObject.GetType() == typeof(Animator))
                                {
                                    animator    = sourceObject as Animator;
                                    componentId = context.AddComponentInProperty(
                                        new WXAnimator(animator, (sourceObject as Animator).gameObject),
                                        animator
                                        );
                                }
                                else
                                {
                                    animator    = (sourceObject as GameObject).GetComponent <Animator>();
                                    componentId = context.AddComponentInProperty(
                                        new WXAnimator(animator, (GameObject)sourceObject),
                                        animator
                                        );
                                }
                            }
                            else
                            {
                                EditorUtility.DisplayDialog("Error", "导出的Playable Director Bingdings格式不支持", "确定");
                                componentId = "";
                            }
                        }
                        else
                        {
                            componentId = "";
                        }
                        if (string.IsNullOrEmpty(componentId))
                        {
                            bindingsArr.AddField(localId, JSONObject.nullJO);
                        }
                        else
                        {
                            bindingsArr.AddField(localId, componentId);
                        }

                        num++;
                    }
                }
            }
            else
            {
                data.AddField("playableAsset", JSONObject.nullJO);
            }
            return(json);
        }
    void ReplaceActorModel(PlayableDirector playableDirector, PlayableBinding playableBinding, GameObject obj, uint rid, string gameObjectName)
    {
        Transform parent = obj.transform.parent;

        SGameEngine.ResourceLoader.Instance.StartCoroutine(LoadActorPrefabCoroutine(obj, playableDirector, playableBinding, parent, rid, gameObjectName));
    }
 public static PlayableBinding Create(string name, UnityEngine.Object key)
 {
     return(PlayableBinding.CreateInternal(name, key, typeof(AudioSource), CreateAudioOutput));
 }
 public static PlayableBinding Create(string name, UnityEngine.Object key)
 {
     return(PlayableBinding.CreateInternal(name, key, typeof(Animator), CreateAnimationOutput));
 }
Exemplo n.º 27
0
 public static Type GetRequiredBindingType(PlayableBinding binding)
 {
     return(binding.outputTargetType);
 }
Exemplo n.º 28
0
 public static PlayableBinding Create(string name, UnityEngine.Object key)
 {
     return(PlayableBinding.CreateInternal(name, key, typeof(RenderTexture), new PlayableBinding.CreateOutputMethod(TexturePlayableBinding.CreateTextureOutput)));
 }
    void OnActorPrefabLoadSuccess(GameObject oldObj, GameObject obj, PlayableDirector playableDirector, PlayableBinding playableBinding, Transform parent, ModelInfo modelInfo)
    {
        Transform trans = obj.transform;

        trans.SetParent(parent);
        trans.localPosition = Vector3.zero;
        trans.localScale    = new Vector3(modelInfo.Scale, modelInfo.Scale, modelInfo.Scale);
        trans.localRotation = Quaternion.identity;

        // 添加Animator组件
        Animator animator = obj.GetComponent <Animator>();

        if (animator == null)
        {
            animator = obj.AddComponent <Animator>();
        }
        if (animator != null)
        {
            animator.updateMode  = AnimatorUpdateMode.Normal;
            animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
        }

        // 删除旧模型
        GameObject.DestroyImmediate(oldObj);

        playableDirector.SetGenericBinding(playableBinding.sourceObject, obj);
    }