59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using UnityEngine;
|
|
|
|
namespace Thousandto.Launcher.ExternalLibs
|
|
{
|
|
/// <summary>
|
|
/// PrefabAsset运行时的处理
|
|
/// </summary>
|
|
public class PrefabAssetRuntimeUtil
|
|
{
|
|
//对纹理设置通过文件路径
|
|
private static Func<Material, string, string, Action<Material, string>, bool> _setTextureWithPathHandler;
|
|
|
|
//对材质的纹理进行复位的Handler
|
|
private static Func<Material,bool> _resetMaterialTextureHandler;
|
|
|
|
//根据名字查找Shader
|
|
private static Func<string,Shader> _findShaderHandler;
|
|
|
|
|
|
public static void SetHandler(Func<Material, string, string, Action<Material, string>, bool> setMatTexHandler, Func<Material, bool> resetMatHandler, Func<string,Shader> findShaderHandler)
|
|
{
|
|
_setTextureWithPathHandler = setMatTexHandler;
|
|
|
|
_resetMaterialTextureHandler = resetMatHandler;
|
|
|
|
_findShaderHandler = findShaderHandler;
|
|
}
|
|
|
|
public static bool ResetMateiralTexture(Material mat)
|
|
{
|
|
if (_resetMaterialTextureHandler != null)
|
|
return _resetMaterialTextureHandler(mat);
|
|
return false;
|
|
}
|
|
|
|
public static bool SetTexture(Material mat, string pName, string texPath, Action<Material, string> callBack)
|
|
{
|
|
if (_setTextureWithPathHandler != null)
|
|
{
|
|
return _setTextureWithPathHandler(mat, pName, texPath, callBack);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static Shader FindShader(string name)
|
|
{
|
|
if (_findShaderHandler != null)
|
|
{
|
|
return _findShaderHandler(name);
|
|
}
|
|
return Shader.Find(name);
|
|
}
|
|
}
|
|
}
|