Example #1
0
        // Token: 0x06000226 RID: 550 RVA: 0x0000AB69 File Offset: 0x00008D69
        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
            if (this.m_Instance != null)
            {
                this.m_Instance.SetActive(true);
                if (m_ParentTrans != null)
                {
                    m_Instance.transform.position =
                        ParticleCtrlUtilities.CalcNodeTransPos(
                            m_Instance.transform.parent, m_ParentTrans
                            , m_PosOffsetInWorld);
                    if (m_initResetRotate)
                    {
                        //try find CharactorRoot
                        var anim = ParticleCtrlUtilities.FindAnimInParent(m_ParentTrans);
                        if (anim != null)
                        {
                            m_Instance.transform.rotation = anim.transform.rotation;
                        }
                        else
                        {
                            m_Instance.transform.localRotation = Quaternion.identity;
                        }
                    }
                    else
                    {
                        m_Instance.transform.rotation = m_ParentTrans.rotation;
                    }
                    //m_Instance.transform.localScale = m_ParentTrans.lossyScale;
                }
                else
                {
                    m_Instance.transform.position = m_PosOffsetInWorld;
                    m_Instance.transform.rotation = Quaternion.identity;
                    //m_Instance.transform.localScale = Vector3.one;
                }
                initWorldPos    = m_Instance.transform.position;
                initWorldRotate = m_Instance.transform.rotation;

                var helper = m_Instance.GetComponent <TimelineFollowTranHelper>();
                if (helper == null)
                {
                    helper = m_Instance.AddComponent <TimelineFollowTranHelper>();
                }
                helper.m_ParentTrans      = m_ParentTrans;
                helper.m_followType       = m_followType;
                helper.m_PosOffsetInWorld = m_PosOffsetInWorld;
                helper.initWorldPos       = initWorldPos;
                helper.initWorldRotate    = initWorldRotate;
            }
        }
Example #2
0
        public static void InitPrticle(GameObject particle, GameObject root)
        {
            if (particle == null)
            {
                //Debug.LogError("特效资源为空");
                return;
            }
            var pTrans = (root == null) ? null : root.transform;

            if (pTrans != null)
            {
                var roleAnim = ParticleCtrlUtilities.FindAnimInParent(pTrans);
                if (roleAnim != null)
                {
                    particle.transform.SetParent(roleAnim.transform.parent);
                }
            }
        }
Example #3
0
 Vector3 CalcDirection()
 {
     if (startRoot == null && m_StartTrans != null)
     {
         var anim = ParticleCtrlUtilities.FindAnimInParent(m_StartTrans);
         if (anim != null)
         {
             startRoot = anim.transform;
         }
     }
     if (endRoot == null && m_EndTrans != null)
     {
         var anim = ParticleCtrlUtilities.FindAnimInParent(m_EndTrans);
         if (anim != null)
         {
             endRoot = anim.transform;
         }
     }
     if (m_revert)
     {
         if (startRoot != null && endRoot != null)
         {
             return(startRoot.position - endRoot.position);
         }
         else
         {
             return(endRoot.forward);
         }
     }
     else
     {
         if (startRoot != null && endRoot != null)
         {
             return(endRoot.position - startRoot.position);
         }
         else
         {
             return(startRoot.forward);
         }
     }
 }
Example #4
0
        // Token: 0x06000224 RID: 548 RVA: 0x0000AA7C File Offset: 0x00008C7C
        void Initialize(GameObject prefabGameObject
                        , Transform startTransform
                        , Transform endTransform
                        , Vector3 startOffsetInWorld
                        , Vector3 endOffsetInWorld
                        , FxFollowType followType
                        , bool initResetRotate
                        , float realLife
                        , float duration
                        , bool revert
                        , float scaleFactor
                        )
        {
            if (startTransform == null || endTransform == null)
            {
                return;
            }
            if (prefabGameObject == null)
            {
                throw new System.ArgumentNullException("Prefab cannot be null");
            }
            if (this.m_Instance != null)
            {
                Debug.LogWarningFormat("Prefab Control Playable ({0}) has already been initialized with a Prefab ({1}).", new object[]
                {
                    prefabGameObject.name,
                    this.m_Instance.name
                });
            }
            else
            {
                this.m_Instance      = Object.Instantiate <GameObject>(prefabGameObject);
                this.m_Instance.name = prefabGameObject.name + " [Timeline]";
                this.m_Instance.SetActive(false);
                ParticleScaleUtility.ScaleEffectNode(this.m_Instance, scaleFactor);
                this.m_StartTrans = startTransform;
                if (this.m_StartTrans != null)
                {
                    var anim = ParticleCtrlUtilities.FindAnimInParent(m_StartTrans);
                    if (anim != null)
                    {
                        this.m_StartRole = anim.transform;
                    }
                }
                this.m_EndTrans = endTransform;
                if (this.m_EndTrans != null)
                {
                    var anim = ParticleCtrlUtilities.FindAnimInParent(m_EndTrans);
                    if (anim != null)
                    {
                        this.m_EndRole = anim.transform;
                    }
                }
                this.m_StartPosOffsetInWorld = startOffsetInWorld;
                this.m_EndPosOffsetInWorld   = endOffsetInWorld;
                this.m_followType            = followType;
                this.m_initResetRotate       = initResetRotate;
                this.m_realLife = realLife;
                this.m_duration = duration;
                this.m_revert   = revert;
                //float roleScale = 1f;
                if (startTransform != null)
                {
                    var roleAnim = ParticleCtrlUtilities.FindAnimInParent(startTransform);
                    if (roleAnim != null)
                    {
                        this.m_Instance.transform.SetParent(roleAnim.transform.parent);
                        //roleScale = roleAnim.transform.lossyScale.x;
                    }
                }
                //ParticleScaleUtility.ScaleEffectNode(this.m_Instance, scaleFactor * roleScale);
                //if (m_ParentTrans != null)
                //{
                //    m_Instance.transform.position = m_ParentTrans.position + m_PosOffsetInWorld;
                //    if( initResetRotate)
                //        m_Instance.transform.rotation = Quaternion.identity;
                //    else
                //        m_Instance.transform.rotation = m_ParentTrans.rotation;
                //    m_Instance.transform.localScale = m_ParentTrans.lossyScale;
                //} else
                //{
                //    m_Instance.transform.position = m_PosOffsetInWorld;
                //    m_Instance.transform.rotation = Quaternion.identity;
                //    m_Instance.transform.localScale = Vector3.one;
                //}

                ParticlePrefabControl.SetHideFlagsRecursive(this.m_Instance);
            }
        }
Example #5
0
        // Called when the state of the playable is set to Play
        public override void OnBehaviourPlay(Playable playable, FrameData info)
        {
            if (m_Instance == null)
            {
                this.m_Instance = fxGo;
                //if (!this.m_Instance.activeInHierarchy)
                //{
                //    this.m_Instance.SetActive(true);
                //}
                //this.m_Instance.name = prefabGameObject.name + " [Timeline]";
                //this.m_Instance.SetActive(false);
                //float roleScale = 1f;
                m_ParentTrans = (sourceGameObject == null) ? null : sourceGameObject.transform;
                //if (m_ParentTrans != null)
                //{
                //    var roleAnim = ParticleCtrlUtilities.FindAnimInParent(m_ParentTrans);

                //    //if (roleAnim != null)
                //    //{
                //    //    roleScale = roleAnim.transform.lossyScale.x;
                //    //}
                //}
                //ParticleScaleUtility.ScaleEffectNode(this.m_Instance, scaleFactor * roleScale);
            }

            if (this.m_Instance != null)
            {
                this.m_Instance.SetActive(true);
                if (m_ParentTrans != null)
                {
                    m_Instance.transform.position = ParticleCtrlUtilities.CalcNodeTransPos(m_Instance.transform.parent, m_ParentTrans, posOffset);
                    if (initResetRotate)
                    {
                        var anim = ParticleCtrlUtilities.FindAnimInParent(m_ParentTrans);
                        if (anim != null)
                        {
                            m_Instance.transform.rotation = anim.transform.rotation;
                        }
                        else
                        {
                            m_Instance.transform.localRotation = Quaternion.identity;
                        }
                    }
                    else
                    {
                        m_Instance.transform.rotation = m_ParentTrans.rotation;
                    }
                }
                else
                {
                    m_Instance.transform.position = posOffset;
                    m_Instance.transform.rotation = Quaternion.identity;
                }
                var particles = m_Instance.GetComponentsInChildren <ParticleSystem>(true);
                if (particles != null && particles.Length > 0)
                {
                    foreach (var p in particles)
                    {
                        p.Simulate(clipIn, false, true);
                        p.Play(false);
                    }
                }

                var matAnims = m_Instance.GetComponentsInChildren <FxHelper.FxHelper_MatAnim>(true);
                if (matAnims != null && matAnims.Length > 0)
                {
                    foreach (var a in matAnims)
                    {
                        a.SetTime(clipIn);
                    }
                }
            }
        }