72 lines
1.5 KiB
C#
72 lines
1.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class FunctionSync_ParticleSystem : OneValueSyncObject
|
|
{
|
|
ParticleSystem ps;
|
|
|
|
private void Start()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
public void Init()
|
|
{
|
|
if(!hasInit)
|
|
{
|
|
ps = GetComponent<ParticleSystem>();
|
|
if (ps != null)
|
|
{
|
|
InitDynamic("ps_" + gameObject.name, CallBack, ValueType.Int);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 操作粒子
|
|
/// </summary>
|
|
/// <param name="state"></param>
|
|
public void SetParticleSystem(ParticleSystemState state)
|
|
{
|
|
myint = (int)state;
|
|
switch (state)
|
|
{
|
|
case ParticleSystemState.Play:
|
|
ps.Play();
|
|
break;
|
|
case ParticleSystemState.Stop:
|
|
ps.Stop();
|
|
break;
|
|
case ParticleSystemState.Pause:
|
|
ps.Pause();
|
|
break;
|
|
}
|
|
SendSync();
|
|
}
|
|
private void CallBack(string id, bool isEnterRoom)
|
|
{
|
|
switch ((ParticleSystemState)myint)
|
|
{
|
|
case ParticleSystemState.Play:
|
|
ps.Play();
|
|
break;
|
|
case ParticleSystemState.Stop:
|
|
ps.Stop();
|
|
break;
|
|
case ParticleSystemState.Pause:
|
|
ps.Pause();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 粒子操作枚举
|
|
/// </summary>
|
|
public enum ParticleSystemState
|
|
{
|
|
Null,
|
|
Play,
|
|
Stop,
|
|
Pause
|
|
}
|