Skip to content

Commit

Permalink
Graphic API Validation (Vulkan), Comment out Layout in ReadmeEditor
Browse files Browse the repository at this point in the history
- ReadMeEditor의 Layout 로드가 레이아웃 초기화를 유발
- 그래픽스 API가 Vulkan이 아닐 경우 알림메시지
  • Loading branch information
shaderqu committed Oct 6, 2021
1 parent 24fd9ea commit 992ca21
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
37 changes: 37 additions & 0 deletions Assets/Scripts/Editor/GraphicsAPIValidate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.Rendering;

internal class GraphicsAPIValidate
{
[InitializeOnLoadMethod]
private static void Check()
{
const string kCheckGraphicsAPIValidateState = "ProjectKaya.GraphicsAPIValidate";

// 에디터 세션 당 한 번만 확인
if (!SessionState.GetBool(kCheckGraphicsAPIValidateState, false ))
{
SessionState.SetBool(kCheckGraphicsAPIValidateState, true);

if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan)
{
if (EditorUtility.DisplayDialog("주의",
"본 프로젝트는 Vulkan 그래픽스 백엔드로 구현되었습니다. UnityHub에서 커맨드라인을 통해 Vulkan 모드로 실행해주세요.",
"세팅 방법 보기", "닫기"))
{
Application.OpenURL("https://github.com/UnityKorea/ProjectKaya#editor-setting");
}
}
}
}

[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
private static void CheckInPlaymode()
{
if (SystemInfo.graphicsDeviceType != GraphicsDeviceType.Vulkan)
{
Debug.LogWarning($"[현재 그래픽스 : {SystemInfo.graphicsDeviceType}] 본 프로젝트는 Vulkan 그래픽스 백엔드로 구현되었습니다. UnityHub에서 커맨드라인을 통해 Vulkan 모드로 실행해주세요.");
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Editor/GraphicsAPIValidate.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Scripts/Editor/Readme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public class Readme : ScriptableObject {
public class Section {
public string heading, text, linkText, url;
}
}
}
19 changes: 14 additions & 5 deletions Assets/Scripts/Editor/ReadmeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,27 @@ static void SelectReadmeAutomatically()

if (readme && !readme.loadedLayout)
{
LoadLayout();
// @bug : break layout.
// LoadLayout();
readme.loadedLayout = true;
}
}
}

static void LoadLayout()
{
var assembly = typeof(EditorApplication).Assembly;
var windowLayoutType = assembly.GetType("UnityEditor.WindowLayout", true);
var method = windowLayoutType.GetMethod("LoadWindowLayout", BindingFlags.Public | BindingFlags.Static);
method.Invoke(null, new object[]{Path.Combine(Application.dataPath, "»Readme/Layout.wlt"), false});
try
{
var assembly = typeof(EditorApplication).Assembly;
var windowLayoutType = assembly.GetType("UnityEditor.WindowLayout", true);
var method = windowLayoutType.GetMethod("LoadWindowLayout", new[] { typeof(string), typeof(bool) });

method.Invoke(null, new object[] { Path.Combine(Application.dataPath, "»Readme/Layout.wlt"), false });
}
catch (Exception e)
{
Debug.LogException(e);
}
}

[MenuItem("Help/Project Kaya README", false, 1800)]
Expand Down

0 comments on commit 992ca21

Please sign in to comment.