using System; using System.Collections; using System.Collections.Generic; using System.Reflection; using Thousandto.Core.Asset; using Thousandto.Core.Base; using UnityEngine; namespace Thousandto.Code.Center { /// /// 场景还原远近处理代理类 /// public class SceneRestoreProxy { #region//静态变量 //SceneRestoreParts类型 private static Type _type; private static Type _utilType; #endregion #region//静态函数 public static void SetSceneRestoreHandle() { if (_utilType == null) { var assemblys = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblys.Length; i++) { var assembly = assemblys[i]; _utilType = assembly.GetType("Thousandto.Launcher.ExternalLibs.SceneRestoreRunTimeUtils"); if (_utilType != null) break; } var miTemp = _utilType.GetMethod("SetHandler", BindingFlags.Public | BindingFlags.Static); if (miTemp != null) { //对纹理设置通过文件路径 Action> texHandler = SceneRestoreTexManger.Instance.SetTexture; Action releaseTexHanle = SceneRestoreTexManger.Instance.ReleaseTexture; Action freeMatHander = MaterialManager.SharedInstance.FreeMaterial; Func newMatHanle = MaterialManager.SharedInstance.NewMaterial; miTemp.Invoke(null, new object[] { texHandler, releaseTexHanle, newMatHanle, freeMatHander }); } } } #endregion #region//构造函数 public SceneRestoreProxy(GameObject root, Action> loadMesh, Action> loadTexture, Action> loadParticeMesh, List boundsList, Dictionary> transDic, Dictionary> typeDic , Vector3? position = null) { Assembly[] assemblys = null; if (_type == null) { assemblys = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblys.Length; i++) { var assembly = assemblys[i]; _type = assembly.GetType("Thousandto.Launcher.ExternalLibs.SceneRestoreParts"); if (_type != null) break; } } if (_type == null) return; System.Reflection.MethodInfo mInfo = _type.GetMethod("InitSceneData", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod); object reflect = Activator.CreateInstance(_type); Vector3 pos = new Vector3(position.Value.x, 0, position.Value.z); if (mInfo != null) { mInfo.Invoke(reflect, new object[] { root, pos, loadMesh, loadTexture, loadParticeMesh, boundsList, transDic, typeDic }); } } #endregion #region//公共函数 public void RestoryLeftParts() { if (_type == null) { var assemblys = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblys.Length; i++) { var assembly = assemblys[i]; _type = assembly.GetType("Thousandto.Launcher.ExternalLibs.SceneRestoreParts"); if (_type != null) break; } } if (_type == null) return; MethodInfo mInfo = _type.GetMethod("RestoreLeftParts", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod); object reflect = Activator.CreateInstance(_type); if (mInfo != null) { mInfo.Invoke(reflect, null); } } #endregion } }