Unity 自动编译后启动Unity
2021-02-04 13:14
标签:ngui 刷新 tor deb lang edit com stat 自动启动 Unity 自动编译后启动Unity 标签:ngui 刷新 tor deb lang edit com stat 自动启动 原文地址:https://www.cnblogs.com/zouqiang/p/12795019.htmlUnity 自动编译后启动Unity
需求由来
解决方案
使用方式
源码
using UnityEditor;
using UnityEngine;
public class AutoCompilePlay : EditorWindow
{
[MenuItem("ZQFramwork/自动编译后启动Unity %&r", false, 0)]
public static void Open()
{
AutoCompilePlay me = GetWindow();
me.titleContent = new GUIContent("自动启动工具");
me.minSize = new Vector2(200, 100);
me.maxSize = me.minSize;
EditorApplication.isPlaying = false;//停止运行
AssetDatabase.Refresh();//刷新资源
}
//每秒10帧调用
private void OnInspectorUpdate()
{
Repaint();//重绘
}
private void OnGUI()
{
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.Space();
EditorGUILayout.Space();
if (EditorUtility.scriptCompilationFailed)
{
Debug.LogError("编译报错");
Close();
return;
}
if (EditorApplication.isCompiling)
{
EditorGUILayout.LabelField("正在编译");
return;
}
if (Application.isPlaying == false)
{
EditorGUILayout.LabelField("正在启动");
EditorApplication.isPlaying = true;
}
else if (Application.isPlaying == true)
{
Close();
}
}
}
文章标题:Unity 自动编译后启动Unity
文章链接:http://soscw.com/index.php/essay/50902.html