107 lines
4.2 KiB
C#
107 lines
4.2 KiB
C#
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
|
|
{
|
|
/// <summary>
|
|
/// 场景还原远近处理代理类
|
|
/// </summary>
|
|
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<string, Action<Texture>> texHandler = SceneRestoreTexManger.Instance.SetTexture;
|
|
Action<string> releaseTexHanle = SceneRestoreTexManger.Instance.ReleaseTexture;
|
|
Action<Material> freeMatHander = MaterialManager.SharedInstance.FreeMaterial;
|
|
Func<Shader,Material> newMatHanle = MaterialManager.SharedInstance.NewMaterial;
|
|
miTemp.Invoke(null, new object[] { texHandler, releaseTexHanle, newMatHanle, freeMatHander });
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region//构造函数
|
|
public SceneRestoreProxy(GameObject root, Action<string, int, Transform, Action<Mesh, string>> loadMesh, Action<string, Action<Texture>> loadTexture,
|
|
Action<string, Action<Mesh>> loadParticeMesh, List<Vector3> boundsList, Dictionary<int, List<Transform>> transDic, Dictionary<int, List<int>> 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
|
|
}
|
|
}
|