116 lines
4.3 KiB
C#
116 lines
4.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
|
|
namespace Thousandto.DIY
|
|
{
|
|
/// <summary>
|
|
/// Unity3D编辑器启动的处理
|
|
/// </summary>
|
|
[InitializeOnLoad]
|
|
public class FuncellEditorStartup
|
|
{
|
|
public static Dictionary<string, AnimationClip> AnimDic = null;
|
|
static FuncellEditorStartup()
|
|
{
|
|
Thousandto.Code.Logic.LuaDataConverter.Load();
|
|
//处理Shader的初始化处理
|
|
EditorApplication.hierarchyWindowChanged -= ShaderStartup.Refresh;
|
|
EditorApplication.hierarchyWindowChanged += ShaderStartup.Refresh;
|
|
Thousandto.Package.PackageProxy.Register();
|
|
ShaderStartup.Refresh();
|
|
|
|
EditorApplication.update -= PackageManger.MyUpdate;
|
|
EditorApplication.update += PackageManger.MyUpdate;
|
|
Thousandto.Package.Tool.PackageOption.CheckAutoPackage();
|
|
|
|
Debug.Log("============================路径 Begin===================================");
|
|
Debug.Log("Environment.CurrentDirectory:" + System.Environment.CurrentDirectory);
|
|
Debug.Log("System.IO.Directory.GetCurrentDirectory():" + System.IO.Directory.GetCurrentDirectory());
|
|
Debug.Log("AppDomain.CurrentDomain.BaseDirectory:" + System.AppDomain.CurrentDomain.BaseDirectory);
|
|
Debug.Log("System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase:" + System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase);
|
|
Debug.Log("EditorApplication.applicationPath:" + EditorApplication.applicationPath);
|
|
Debug.Log("EditorApplication.applicationContentsPath:" + EditorApplication.applicationContentsPath);
|
|
Debug.Log("============================路径 End===================================");
|
|
|
|
//加载所有玩家动作
|
|
var allAnim = AssetDatabase.FindAssets("t:AnimationClip");
|
|
if(AnimDic == null)
|
|
{
|
|
AnimDic = new Dictionary<string, AnimationClip>(allAnim.Length);
|
|
}
|
|
for (int i = 0; i < allAnim.Length; ++i)
|
|
{
|
|
var path = AssetDatabase.GUIDToAssetPath(allAnim[i]);
|
|
if (path.Contains("RawResources/player") && !AnimDic.ContainsKey(path))
|
|
{
|
|
var anim = AssetDatabase.LoadAssetAtPath<AnimationClip>(path);
|
|
GameObject.DontDestroyOnLoad(anim);
|
|
AnimDic.Add(path, anim);
|
|
}
|
|
}
|
|
}
|
|
|
|
[UnityEditor.Callbacks.DidReloadScripts]
|
|
static void DidReloadScripts()
|
|
{
|
|
Thousandto.Code.Logic.LuaDataConverter.Load();
|
|
Debug.Log("重新加载所有脚本!!");
|
|
}
|
|
|
|
|
|
|
|
#region//子类处理
|
|
//Shader的启动处理
|
|
private class ShaderStartup
|
|
{
|
|
|
|
//刷新
|
|
public static void Refresh()
|
|
{
|
|
if (!Application.isPlaying)
|
|
{
|
|
|
|
//在编辑器状态下,不出来阴影
|
|
Shader.SetGlobalTexture("_MyShadowMap", Texture2D.blackTexture);
|
|
Shader.SetGlobalFloat("_ShadowIntensity", 1f);
|
|
Shader.EnableKeyword("_GONBEST_RAIN_BUMP_ON");
|
|
Shader.EnableKeyword("_GONBEST_SHADOW_ON");
|
|
Shader.EnableKeyword("LIGHTMAP_ON");
|
|
}
|
|
}
|
|
|
|
//读取纹理
|
|
private static Texture GetTexture(string path)
|
|
{
|
|
var tex = Resources.Load<Texture>(path);
|
|
if (tex == null)
|
|
{
|
|
Debug.LogError("没有在Resource目录中找到纹理:" + path);
|
|
}
|
|
return tex;
|
|
}
|
|
}
|
|
|
|
private class PackageManger
|
|
{
|
|
private static bool isCheck = false;
|
|
|
|
public static void CheckAutoPackage()
|
|
{
|
|
if (isCheck)
|
|
Thousandto.Package.Tool.PackageOption.CheckAutoPackage();
|
|
isCheck = true;
|
|
}
|
|
public static void MyUpdate()
|
|
{
|
|
Thousandto.Package.Tool.PackageCommand.Update();
|
|
Thousandto.Package.Tool.PackageOption.Update();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|