Пример #1
0
 // Start is called before the first frame update
 void Start()
 {
     //set timeToKill
     UnityEngine.ParticleSystem.MainModule module = gameObject.GetComponent <ParticleSystem>().main;
     timeToKill = module.duration + module.startLifetime.constant;
     StartCoroutine("KillParticleEffect");
 }
 // Update is called once per frame
 void Update()
 {
     UnityEngine.ParticleSystem.MainModule main = background.GetComponent <ParticleSystem>().main;
     if (isHole)
     {
         main.startColor = Color.white;
     }
     else
     {
         main.startColor = Color.black;
     }
 }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.ParticleSystem.MainModule o;
         o = new UnityEngine.ParticleSystem.MainModule();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static int QPYX_get_main_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.ParticleSystem QPYX_obj_YXQP = (UnityEngine.ParticleSystem)QPYX_o_YXQP;
            UnityEngine.ParticleSystem.MainModule QPYX_ret_YXQP = QPYX_obj_YXQP.main;
            ToLua.PushValue(L_YXQP, QPYX_ret_YXQP);
            return(1);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index main on a nil value"));
        }
    }
    static int get_main(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.ParticleSystem            obj = (UnityEngine.ParticleSystem)o;
            UnityEngine.ParticleSystem.MainModule ret = obj.main;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index main on a nil value"));
        }
    }
    static int get_main(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.ParticleSystem.main");
#endif
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.ParticleSystem            obj = (UnityEngine.ParticleSystem)o;
            UnityEngine.ParticleSystem.MainModule ret = obj.main;
            ToLua.PushValue(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index main on a nil value"));
        }
    }
    private static void FillMainModule(UnityEngine.ParticleSystem ups, ParticleSystem ps)
    {
        UnityEngine.ParticleSystem.MainModule main = ups.main;
        if (ps.Emitter.startTime is OneDConst)
        {
            if (!ps.RenderParam.Loop)
            {
                main.duration = ps.Emitter.startTime.getMaxValue() + 0.1f;
            }
            else
            {
                var curve = ps.Emitter.lifeTime.getCurve();
                main.duration = UnityEngine.Mathf.Max(curve.Evaluate(0.0f), curve.Evaluate(1.0f));
            }
        }
        else
        {
            var curve = ps.Emitter.lifeTime.getCurve();
            main.duration = UnityEngine.Mathf.Max(curve.Evaluate(0.0f), curve.Evaluate(1.0f));
        }
        main.maxParticles    = ps.RenderParam.ParticleNumber * 2;
        main.loop            = ps.RenderParam.Loop;
        main.simulationSpace = ps.RenderParam.IsWorldParticle ? ParticleSystemSimulationSpace.World : ParticleSystemSimulationSpace.Local;
        main.prewarm         = ps.RenderParam.Prewarm > 0.0f ? true : false;

        //自带mesh和原来的mesh不一样,这是世界的旋转
        //如果不是ParticleSystemRenderMode.Mesh模式,quad是法线是+y轴的,发色器-90度后,quad法线朝向-z轴
        bool exchange = (ParticleSystemRenderMode.Mesh == (ParticleSystemRenderMode)ps.RenderParam.BillboardType);

        //旋转轴向
        if (ps.RenderParam.RotateAxis == RenderParam.RotateAxis_X)
        {
            main.startRotation3D = true;
            main.startRotationX  = ps.Emitter.rot.getCurve(ValueTypeUtil.CurveType.Normal);
            main.startRotationY  = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
            main.startRotationZ  = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
        }
        //绕y轴旋转,即z轴旋转
        else if (ps.RenderParam.RotateAxis == RenderParam.RotateAxis_Y)
        {
            main.startRotation3D = true;
            main.startRotationX  = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
            if (exchange)
            {
                main.startRotationY = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
                main.startRotationZ = ps.Emitter.rot.getCurve(ValueTypeUtil.CurveType.Normal);
            }
            else
            {
                main.startRotationY = ps.Emitter.rot.getCurve(ValueTypeUtil.CurveType.Normal);
                main.startRotationZ = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
            }
        }
        else if (ps.RenderParam.RotateAxis == RenderParam.RotateAxis_Z)
        {
            main.startRotation3D = true;
            main.startRotationX  = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
            if (exchange)
            {
                main.startRotationY = ps.Emitter.rot.getNegativeCurve(ValueTypeUtil.CurveType.Normal);
                main.startRotationZ = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
            }
            else
            {
                main.startRotationY = new UnityEngine.ParticleSystem.MinMaxCurve(0.0f, 0.0f);
                main.startRotationZ = ps.Emitter.rot.getCurve(ValueTypeUtil.CurveType.Normal);
            }
        }
        else
        {
            main.startRotation3D = false;
        }


        if (ps.Emitter.UniformScale)
        {
            main.startSize3D = false;
            //main.startSizeX = ps.Emitter.sizeX.getCurve(ValueTypeUtil.CurveType.Normal, 1.0f / ups.transform.localScale[0]);
            main.startSizeX = ps.Emitter.sizeX.getCurve(ValueTypeUtil.CurveType.Normal);
            main.startSizeY = main.startSizeX;
            main.startSizeZ = main.startSizeX;
        }
        else
        {
            main.startSize3D = true;
            main.startSizeX  = ps.Emitter.sizeX.getCurve(ValueTypeUtil.CurveType.Normal);
            main.startSizeY  = ps.Emitter.sizeY.getCurve(ValueTypeUtil.CurveType.Normal);
            main.startSizeZ  = ps.Emitter.sizeZ.getCurve(ValueTypeUtil.CurveType.Normal);
        }

        main.startLifetime = ps.Emitter.lifeTime.getCurve();
        main.startSpeed    = ps.Emitter.velocity.getCurve();

        main.startColor = ps.Emitter.color.getGradient();
        var alpha = ps.Emitter.alpha.getCurve();

        main.startColor = MergeColorAndAlpha(main.startColor, alpha);
    }