Unity拖尾特效在重置位置重置拖尾方法

加载完的特效或者重复使用的拖尾特效,在重新设置起始位置的时候不想要拖尾
 

void ClearTrailRenderPoint ( GameObject gameObject )
        {
            if ( gameObject != null )
            {
                TrailRenderer [ ] trailRenderers;
                if ( !gameObjectTrailRenders.ContainsKey ( gameObject ) ) 
                {
                    gameObjectTrailRenders.Add ( gameObject, gameObject.GetComponentsInChildren ( ) );
                }
                if ( gameObjectTrailRenders.TryGetValue ( gameObject, out trailRenderers ) )
                {
                    int length = trailRenderers.Length;
                    if ( length > 0 )
                    {
                        for ( var n = 0; n < length; ++n )
                        {
                            trailRenderers [ n ].Clear ( );
                        }
                    }
                }
            }
        }

 

你可能感兴趣的:(Unity拖尾特效在重置位置重置拖尾方法)