using System.Collections; using System.Collections.Generic; using System.Linq; using Plugins.JNGame.Sync.Frame.game; using UnityEngine; namespace Game.Plugins.App.Sync { public class JNGSyncFrameEntrust : JNGSyncFrameDefault { private IEnumerable _components; public IEnumerable Components => _components; public Component[] allow; public override void OnSyncLoad() { //获取非同步的组件 _components = this.GetComponents() .Where(item => !(item is IJNSyncFrameComponent)) .Where(item => !(item is Transform)) .Where(item => !(allow.Contains(item))); Debug.Log($"{this.NID} 有{Components.Count()}组件不是同步组件 尝试接管同步 请保证被接管的组件有enabled 同时被接管的组件 enabled 禁止修改"); foreach (var component in Components) { var property = component.GetType().GetProperty("enabled"); if (property == null) { Debug.Log($"{this.NID} 有组件不是同步组件 并且没有 enabled 为了防止不同步 直接删除!"); Destroy(component); continue; } property.SetValue(component,false); } _components = this.GetComponents() .Where(item => !(item.GetType().IsAssignableFrom(typeof(IJNSyncFrameComponent)))); } public override void OnSyncUpdate(int dt, JNFrameInfo frame, Object input) { base.OnSyncUpdate(dt, frame, input); } } }