Flatkit 추가 및 설정
This commit is contained in:
16
Assets/FlatKit/Utils/FlatKit.Utils.Editor.asmdef
Normal file
16
Assets/FlatKit/Utils/FlatKit.Utils.Editor.asmdef
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "FlatKit.Utils.Editor",
|
||||
"rootNamespace": "",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
14
Assets/FlatKit/Utils/FlatKit.Utils.Editor.asmdef.meta
Normal file
14
Assets/FlatKit/Utils/FlatKit.Utils.Editor.asmdef.meta
Normal file
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 389250d696797554d91cc43711a52286
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 143368
|
||||
packageName: 'Flat Kit: Toon Shading and Water'
|
||||
packageVersion: 4.9.8
|
||||
assetPath: Assets/FlatKit/Utils/FlatKit.Utils.Editor.asmdef
|
||||
uploadId: 834448
|
||||
92
Assets/FlatKit/Utils/MeshSmoother.cs
Normal file
92
Assets/FlatKit/Utils/MeshSmoother.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FlatKit {
|
||||
public static class MeshSmoother {
|
||||
private const int SmoothNormalUVChannel = 2;
|
||||
|
||||
/// <summary>
|
||||
/// Performs normal smoothing on the current mesh filter associated with this component asynchronously.
|
||||
/// This method will not try and re-smooth meshes which have already been smoothed.
|
||||
/// </summary>
|
||||
/// <returns>A task which will complete once normal smoothing is finished.</returns>
|
||||
public static Task SmoothNormalsA(Mesh mesh) {
|
||||
// Create a copy of the vertices and normals and apply the smoothing in an async task.
|
||||
var vertices = mesh.vertices;
|
||||
var normals = mesh.normals;
|
||||
var asyncTask = Task.Run(() => CalculateSmoothNormals(vertices, normals));
|
||||
|
||||
// Once the async task is complete, apply the smoothed normals to the mesh on the main thread.
|
||||
return asyncTask.ContinueWith(i => { mesh.SetUVs(SmoothNormalUVChannel, i.Result); },
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
|
||||
public static void SmoothNormals(Mesh mesh) {
|
||||
var result = CalculateSmoothNormals(mesh.vertices, mesh.normals);
|
||||
mesh.SetUVs(SmoothNormalUVChannel, result);
|
||||
}
|
||||
|
||||
public static void ClearNormalsUV(Mesh mesh) {
|
||||
mesh.SetUVs(SmoothNormalUVChannel, (Vector3[])null);
|
||||
}
|
||||
|
||||
public static bool HasSmoothNormals(Mesh mesh) {
|
||||
return mesh.uv3 != null && mesh.uv3.Length > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method groups vertices in a mesh that share the same location in space then averages the normals of those vertices.
|
||||
/// For example, if you imagine the 3 vertices that make up one corner of a cube. Normally there will be 3 normals facing in the direction
|
||||
/// of each face that touches that corner. This method will take those 3 normals and average them into a normal that points in the
|
||||
/// direction from the center of the cube to the corner of the cube.
|
||||
/// </summary>
|
||||
/// <param name="vertices">A list of vertices that represent a mesh.</param>
|
||||
/// <param name="normals">A list of normals that correspond to each vertex passed in via the vertices param.</param>
|
||||
/// <returns>A list of normals which are smoothed, or averaged, based on share vertex position.</returns>
|
||||
public static List<Vector3>
|
||||
CalculateSmoothNormals(IReadOnlyList<Vector3> vertices, IReadOnlyList<Vector3> normals) {
|
||||
var watch = System.Diagnostics.Stopwatch.StartNew();
|
||||
|
||||
// Group all vertices that share the same location in space.
|
||||
var groupedVertices = new Dictionary<Vector3, List<KeyValuePair<int, Vector3>>>();
|
||||
|
||||
for (int i = 0; i < vertices.Count; ++i) {
|
||||
var vertex = vertices[i];
|
||||
|
||||
if (!groupedVertices.TryGetValue(vertex, out var group)) {
|
||||
group = new List<KeyValuePair<int, Vector3>>();
|
||||
groupedVertices[vertex] = group;
|
||||
}
|
||||
|
||||
group.Add(new KeyValuePair<int, Vector3>(i, vertex));
|
||||
}
|
||||
|
||||
var smoothNormals = new List<Vector3>(normals);
|
||||
|
||||
// If we don't hit the degenerate case of each vertex is its own group (no vertices shared a location), average the normals of each group.
|
||||
if (groupedVertices.Count != vertices.Count) {
|
||||
foreach (var group in groupedVertices) {
|
||||
var smoothingGroup = group.Value;
|
||||
|
||||
// No need to smooth a group of one.
|
||||
if (smoothingGroup.Count != 1) {
|
||||
var smoothedNormal = smoothingGroup.Aggregate(Vector3.zero,
|
||||
(current, vertex) => current + normals[vertex.Key]);
|
||||
smoothedNormal.Normalize();
|
||||
|
||||
foreach (var vertex in smoothingGroup) {
|
||||
smoothNormals[vertex.Key] = smoothedNormal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"<b>[Flat Kit]</b> Generated smooth normals for <i>{vertices.Count}</i> vertices in " +
|
||||
$"<i>{watch.ElapsedMilliseconds}</i> ms.");
|
||||
|
||||
return smoothNormals;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Assets/FlatKit/Utils/MeshSmoother.cs.meta
Normal file
18
Assets/FlatKit/Utils/MeshSmoother.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7876b5b65fd9844a852a6352eb2c8c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 143368
|
||||
packageName: 'Flat Kit: Toon Shading and Water'
|
||||
packageVersion: 4.9.8
|
||||
assetPath: Assets/FlatKit/Utils/MeshSmoother.cs
|
||||
uploadId: 834448
|
||||
8
Assets/FlatKit/Utils/Readme.meta
Normal file
8
Assets/FlatKit/Utils/Readme.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad6801a51b9294e59b52d1cb2fcf0e4b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/FlatKit/Utils/Readme/Editor.meta
Normal file
8
Assets/FlatKit/Utils/Readme/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e10100cd3416a421cb4aeecbe8f8fab3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
76
Assets/FlatKit/Utils/Readme/Editor/FlatKitReadme.cs
Normal file
76
Assets/FlatKit/Utils/Readme/Editor/FlatKitReadme.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEditor;
|
||||
using UnityEditor.PackageManager;
|
||||
using UnityEngine;
|
||||
using PackageInfo = UnityEditor.PackageManager.PackageInfo;
|
||||
|
||||
// ReSharper disable UnusedMember.Local
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
|
||||
namespace FlatKit {
|
||||
#if FLAT_KIT_DEV
|
||||
[CreateAssetMenu(fileName = "Readme", menuName = "FlatKit/Internal/Readme", order = 0)]
|
||||
#endif // FLAT_KIT_DEV
|
||||
|
||||
[ExecuteAlways]
|
||||
public class FlatKitReadme : ScriptableObject {
|
||||
[NonSerialized]
|
||||
public bool FlatKitInstalled;
|
||||
|
||||
[NonSerialized]
|
||||
public readonly string FlatKitVersion = "4.9.8";
|
||||
|
||||
[NonSerialized]
|
||||
public bool? UrpInstalled;
|
||||
|
||||
[NonSerialized]
|
||||
[CanBeNull]
|
||||
public string PackageManagerError;
|
||||
|
||||
[NonSerialized]
|
||||
public string UrpVersionInstalled = "N/A";
|
||||
|
||||
[NonSerialized]
|
||||
public string UnityVersion = Application.unityVersion;
|
||||
|
||||
private const string UrpPackageID = "com.unity.render-pipelines.universal";
|
||||
|
||||
private static readonly GUID StylizedShaderGuid = new GUID("bee44b4a58655ee4cbff107302a3e131");
|
||||
|
||||
public void Refresh() {
|
||||
UrpInstalled = false;
|
||||
FlatKitInstalled = false;
|
||||
PackageManagerError = null;
|
||||
|
||||
PackageCollection packages = GetPackageList();
|
||||
foreach (PackageInfo p in packages) {
|
||||
if (p.name == UrpPackageID) {
|
||||
UrpInstalled = true;
|
||||
UrpVersionInstalled = p.version;
|
||||
}
|
||||
}
|
||||
|
||||
string path = AssetDatabase.GUIDToAssetPath(StylizedShaderGuid.ToString());
|
||||
var flatKitSourceAsset = AssetDatabase.LoadAssetAtPath<Shader>(path);
|
||||
FlatKitInstalled = flatKitSourceAsset != null;
|
||||
|
||||
UnityVersion = Application.unityVersion;
|
||||
}
|
||||
|
||||
private PackageCollection GetPackageList() {
|
||||
var listRequest = Client.List(true);
|
||||
|
||||
while (listRequest.Status == StatusCode.InProgress) { }
|
||||
|
||||
if (listRequest.Status == StatusCode.Failure) {
|
||||
PackageManagerError = listRequest.Error.message;
|
||||
// 22b5f7ed-989d-49d1-90d9-c62d76c3081a
|
||||
Debug.LogWarning("[Flat Kit] Failed to get packages from Package Manager.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return listRequest.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/FlatKit/Utils/Readme/Editor/FlatKitReadme.cs.meta
Normal file
10
Assets/FlatKit/Utils/Readme/Editor/FlatKitReadme.cs.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 315ffe2a4859447e87bd0c041086908f
|
||||
timeCreated: 1612836264
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 143368
|
||||
packageName: 'Flat Kit: Toon Shading and Water'
|
||||
packageVersion: 4.9.8
|
||||
assetPath: Assets/FlatKit/Utils/Readme/Editor/FlatKitReadme.cs
|
||||
uploadId: 834448
|
||||
39
Assets/FlatKit/Utils/Readme/Editor/NetworkManager.cs
Normal file
39
Assets/FlatKit/Utils/Readme/Editor/NetworkManager.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace FlatKit {
|
||||
public static class NetworkManager {
|
||||
private static UnityWebRequest _request;
|
||||
|
||||
public static void GetVersion(Action<string> callback) {
|
||||
const string url = "https://dustyroom.com/flat-kit/version.txt";
|
||||
GetRequest(url, request => {
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
if (request.result == UnityWebRequest.Result.Success) {
|
||||
#else
|
||||
if (!request.isNetworkError && !request.isHttpError) {
|
||||
#endif
|
||||
var text = request.downloadHandler.text;
|
||||
callback(text);
|
||||
} else {
|
||||
Debug.LogError($"[Flat Kit] {request.error}: {request.downloadHandler.text}.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void GetRequest(string url, Action<UnityWebRequest> callback) {
|
||||
if (_request != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
_request = UnityWebRequest.Get(url);
|
||||
var op = _request.SendWebRequest();
|
||||
op.completed += operation => {
|
||||
callback(_request);
|
||||
_request.Dispose();
|
||||
_request = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/FlatKit/Utils/Readme/Editor/NetworkManager.cs.meta
Normal file
10
Assets/FlatKit/Utils/Readme/Editor/NetworkManager.cs.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 267005974f054ef49399d2341c57a950
|
||||
timeCreated: 1620539101
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 143368
|
||||
packageName: 'Flat Kit: Toon Shading and Water'
|
||||
packageVersion: 4.9.8
|
||||
assetPath: Assets/FlatKit/Utils/Readme/Editor/NetworkManager.cs
|
||||
uploadId: 834448
|
||||
354
Assets/FlatKit/Utils/Readme/Editor/ReadmeEditor.cs
Normal file
354
Assets/FlatKit/Utils/Readme/Editor/ReadmeEditor.cs
Normal file
@@ -0,0 +1,354 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace FlatKit {
|
||||
[CustomEditor(typeof(FlatKitReadme))]
|
||||
public class ReadmeEditor : Editor {
|
||||
private static readonly string AssetName = "Flat Kit";
|
||||
|
||||
private static readonly GUID UnityPackageUrpGuid = new GUID("41e59f562b69648719f2424c438758f3");
|
||||
private static readonly GUID UnityPackageBuiltInGuid = new GUID("f4227764308e84f89a765fbf315e2945");
|
||||
|
||||
// 2b85f0b7-3248-4e28-8900-a861e01241ba
|
||||
// 95b02117-de66-49f0-91e7-cc5f4291cf90
|
||||
|
||||
private FlatKitReadme _readme;
|
||||
private bool _showingVersionMessage;
|
||||
private string _versionLatest;
|
||||
|
||||
private bool _showingClearCacheMessage;
|
||||
private bool _cacheClearedSuccessfully;
|
||||
|
||||
private void OnEnable() {
|
||||
_readme = serializedObject.targetObject as FlatKitReadme;
|
||||
if (_readme == null) {
|
||||
Debug.LogError($"[{AssetName}] Readme error.");
|
||||
return;
|
||||
}
|
||||
|
||||
_readme.Refresh();
|
||||
_showingVersionMessage = false;
|
||||
_showingClearCacheMessage = false;
|
||||
_versionLatest = null;
|
||||
|
||||
AssetDatabase.importPackageStarted += OnImportPackageStarted;
|
||||
AssetDatabase.importPackageCompleted += OnImportPackageCompleted;
|
||||
AssetDatabase.importPackageFailed += OnImportPackageFailed;
|
||||
AssetDatabase.importPackageCancelled += OnImportPackageCancelled;
|
||||
}
|
||||
|
||||
private void OnDisable() {
|
||||
AssetDatabase.importPackageStarted -= OnImportPackageStarted;
|
||||
AssetDatabase.importPackageCompleted -= OnImportPackageCompleted;
|
||||
AssetDatabase.importPackageFailed -= OnImportPackageFailed;
|
||||
AssetDatabase.importPackageCancelled -= OnImportPackageCancelled;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
{
|
||||
EditorGUILayout.LabelField(AssetName, EditorStyles.boldLabel);
|
||||
DrawUILine(Color.gray, 1, 0);
|
||||
EditorGUILayout.LabelField($"Version {_readme.FlatKitVersion}", EditorStyles.miniLabel);
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Documentation")) {
|
||||
OpenDocumentation();
|
||||
}
|
||||
|
||||
{
|
||||
if (_showingVersionMessage) {
|
||||
if (_versionLatest == null) {
|
||||
EditorGUILayout.HelpBox($"Checking the latest version...", MessageType.None);
|
||||
} else {
|
||||
EditorGUILayout.Space(20);
|
||||
|
||||
var local = Version.Parse(_readme.FlatKitVersion);
|
||||
var remote = Version.Parse(_versionLatest);
|
||||
if (local >= remote) {
|
||||
EditorGUILayout.HelpBox($"You have the latest version! {_readme.FlatKitVersion}.",
|
||||
MessageType.Info);
|
||||
} else {
|
||||
EditorGUILayout.HelpBox(
|
||||
$"Update needed. " +
|
||||
$"The latest version is {_versionLatest}, but you have {_readme.FlatKitVersion}.",
|
||||
MessageType.Warning);
|
||||
|
||||
#if !UNITY_2020_3_OR_NEWER
|
||||
EditorGUILayout.HelpBox(
|
||||
$"Please update Unity to 2020.3 or newer to get the latest version of Flat Kit.",
|
||||
MessageType.Error);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Check for updates")) {
|
||||
_showingVersionMessage = true;
|
||||
_versionLatest = null;
|
||||
CheckVersion();
|
||||
}
|
||||
|
||||
if (_showingVersionMessage) {
|
||||
EditorGUILayout.Space(20);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
if (GUILayout.Button("Open support ticket")) {
|
||||
OpenSupportTicket();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Copy debug info")) {
|
||||
CopyDebugInfoToClipboard();
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
{
|
||||
if (!_readme.FlatKitInstalled) {
|
||||
EditorGUILayout.Separator();
|
||||
DrawUILine(Color.yellow, 1, 0);
|
||||
|
||||
EditorGUILayout.HelpBox(
|
||||
$"Before using {AssetName} you need to unpack it depending on your project's Render Pipeline.",
|
||||
MessageType.Warning);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUILayout.LabelField($"Unpack {AssetName} for", EditorStyles.label);
|
||||
if (GUILayout.Button("URP")) {
|
||||
UnpackFlatKitUrp();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Built-in RP")) {
|
||||
UnpackFlatKitBuiltInRP();
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
DrawUILine(Color.yellow, 1, 0);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_readme.PackageManagerError)) {
|
||||
EditorGUILayout.Separator();
|
||||
DrawUILine(Color.yellow, 1, 0);
|
||||
EditorGUILayout.HelpBox($"Package Manager error: {_readme.PackageManagerError}", MessageType.Warning);
|
||||
DrawUILine(Color.yellow, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
DrawUILine(Color.gray, 1, 20);
|
||||
EditorGUILayout.LabelField("Package Manager", EditorStyles.label);
|
||||
|
||||
if (GUILayout.Button("Clear cache")) {
|
||||
ClearPackageCache();
|
||||
}
|
||||
|
||||
if (_showingClearCacheMessage) {
|
||||
if (_cacheClearedSuccessfully) {
|
||||
EditorGUILayout.HelpBox(
|
||||
$"Successfully removed cached packages. \n" +
|
||||
$"Please re-download {AssetName} in the Package Manager.", MessageType.Info);
|
||||
} else {
|
||||
EditorGUILayout.HelpBox($"Could not find or clear package cache.", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
|
||||
DrawColorSpaceCheck();
|
||||
|
||||
{
|
||||
DrawUILine(Color.gray, 1, 20);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUILayout.LabelField("Debug info", EditorStyles.miniBoldLabel);
|
||||
|
||||
GUILayout.BeginVertical();
|
||||
if (GUILayout.Button("Copy", EditorStyles.miniButtonLeft)) {
|
||||
CopyDebugInfoToClipboard();
|
||||
}
|
||||
|
||||
if (EditorGUIUtility.systemCopyBuffer == GetDebugInfoString()) {
|
||||
EditorGUILayout.LabelField("Copied!", EditorStyles.miniLabel);
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
var debugInfo = GetDebugInfo();
|
||||
var style = new GUIStyle(EditorStyles.miniLabel) {wordWrap = true};
|
||||
foreach (var s in debugInfo) {
|
||||
EditorGUILayout.LabelField($" " + s, style);
|
||||
}
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetDebugInfo() {
|
||||
var renderPipelineAsset = GraphicsSettings.currentRenderPipeline;
|
||||
if (renderPipelineAsset == null) {
|
||||
renderPipelineAsset = GraphicsSettings.defaultRenderPipeline;
|
||||
}
|
||||
|
||||
var rpAssetName = renderPipelineAsset == null ? "N/A" : renderPipelineAsset.name;
|
||||
|
||||
var renderingPath = "Unknown";
|
||||
if (Shader.IsKeywordEnabled("_FORWARD_PLUS")) {
|
||||
renderingPath = "Forward+";
|
||||
}
|
||||
|
||||
var info = new List<string> {
|
||||
$"{AssetName} version {_readme.FlatKitVersion}",
|
||||
$"Unity {_readme.UnityVersion}",
|
||||
$"Dev platform: {Application.platform}",
|
||||
$"Target platform: {EditorUserBuildSettings.activeBuildTarget}",
|
||||
$"URP installed: {_readme.UrpInstalled}, version {_readme.UrpVersionInstalled}",
|
||||
$"Render pipeline: {Shader.globalRenderPipeline}",
|
||||
$"Render pipeline asset: {rpAssetName}",
|
||||
$"Rendering path: {renderingPath}",
|
||||
$"Color space: {PlayerSettings.colorSpace}"
|
||||
};
|
||||
|
||||
var qualityConfig = QualitySettings.renderPipeline == null ? "N/A" : QualitySettings.renderPipeline.name;
|
||||
info.Add($"Quality config: {qualityConfig}");
|
||||
|
||||
var graphicsConfig = GraphicsSettings.currentRenderPipeline == null
|
||||
? "N/A"
|
||||
: GraphicsSettings.currentRenderPipeline.name;
|
||||
info.Add($"Graphics config: {graphicsConfig}");
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private string GetDebugInfoString() {
|
||||
var info = GetDebugInfo();
|
||||
|
||||
{
|
||||
var keywords = new List<string>();
|
||||
foreach (var keyword in Shader.enabledGlobalKeywords) {
|
||||
if (Shader.IsKeywordEnabled(keyword)) {
|
||||
keywords.Add(keyword.name);
|
||||
}
|
||||
}
|
||||
|
||||
var keywordsInfo = "Enabled global keywords: " + string.Join(", ", keywords);
|
||||
info.Add(keywordsInfo);
|
||||
}
|
||||
|
||||
return string.Join("\n", info);
|
||||
}
|
||||
|
||||
private void CopyDebugInfoToClipboard() {
|
||||
EditorGUIUtility.systemCopyBuffer = GetDebugInfoString();
|
||||
}
|
||||
|
||||
private void ClearPackageCache() {
|
||||
string path = string.Empty;
|
||||
if (Application.platform == RuntimePlatform.OSXEditor) {
|
||||
path = "~/Library/Unity/Asset Store-5.x/Dustyroom/";
|
||||
}
|
||||
|
||||
if (Application.platform == RuntimePlatform.LinuxEditor) {
|
||||
path = "~/.local/share/unity3d/Asset Store-5.x/Dustyroom/";
|
||||
}
|
||||
|
||||
if (Application.platform == RuntimePlatform.WindowsEditor) {
|
||||
// This wouldn't understand %APPDATA%.
|
||||
path = Application.persistentDataPath.Substring(0,
|
||||
Application.persistentDataPath.IndexOf("AppData", StringComparison.Ordinal)) +
|
||||
"/AppData/Roaming/Unity/Asset Store-5.x/Dustyroom";
|
||||
}
|
||||
|
||||
if (path == string.Empty) return;
|
||||
|
||||
_cacheClearedSuccessfully |= FileUtil.DeleteFileOrDirectory(path);
|
||||
_showingClearCacheMessage = true;
|
||||
}
|
||||
|
||||
private void UnpackFlatKitUrp() {
|
||||
string path = AssetDatabase.GUIDToAssetPath(UnityPackageUrpGuid.ToString());
|
||||
if (path == null) {
|
||||
Debug.LogError($"<b>[{AssetName}]</b> Could not find the URP package.");
|
||||
} else {
|
||||
AssetDatabase.ImportPackage(path, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void UnpackFlatKitBuiltInRP() {
|
||||
string path = AssetDatabase.GUIDToAssetPath(UnityPackageBuiltInGuid.ToString());
|
||||
if (path == null) {
|
||||
Debug.LogError($"<b>[{AssetName}]</b> Could not find the Built-in RP package.");
|
||||
} else {
|
||||
AssetDatabase.ImportPackage(path, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnImportPackageStarted(string packageName) { }
|
||||
|
||||
private void OnImportPackageCompleted(string packageName) {
|
||||
_readme.Refresh();
|
||||
Repaint();
|
||||
EditorUtility.SetDirty(this);
|
||||
}
|
||||
|
||||
private void OnImportPackageFailed(string packageName, string errorMessage) {
|
||||
Debug.LogError($"<b>[{AssetName}]</b> Failed to unpack {packageName}: {errorMessage}.");
|
||||
}
|
||||
|
||||
private void OnImportPackageCancelled(string packageName) {
|
||||
Debug.LogError($"<b>[{AssetName}]</b> Cancelled unpacking {packageName}.");
|
||||
}
|
||||
|
||||
private void DrawColorSpaceCheck() {
|
||||
if (PlayerSettings.colorSpace != ColorSpace.Linear) {
|
||||
DrawUILine(Color.gray, 1, 20);
|
||||
EditorGUILayout.HelpBox(
|
||||
$"{AssetName} demo scenes were created for the Linear color space, but your project is " +
|
||||
$"using {PlayerSettings.colorSpace}.\nThis may result in the demo scenes appearing slightly " +
|
||||
$"different compared to the Asset Store screenshots.\nOptionally, you may switch the color space " +
|
||||
$"using the button below.",
|
||||
MessageType.Warning);
|
||||
|
||||
if (GUILayout.Button("Switch player settings to Linear color space")) {
|
||||
PlayerSettings.colorSpace = ColorSpace.Linear;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckVersion() {
|
||||
NetworkManager.GetVersion(version => { _versionLatest = version; });
|
||||
}
|
||||
|
||||
private void OpenSupportTicket() {
|
||||
Application.OpenURL("https://github.com/Dustyroom/flat-kit-doc/issues/new/choose");
|
||||
}
|
||||
|
||||
private void OpenDocumentation() {
|
||||
Application.OpenURL("https://flatkit.dustyroom.com");
|
||||
}
|
||||
|
||||
private static void DrawUILine(Color color, int thickness = 2, int padding = 10) {
|
||||
Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
|
||||
r.height = thickness;
|
||||
r.y += padding / 2f;
|
||||
r.x -= 2;
|
||||
EditorGUI.DrawRect(r, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Assets/FlatKit/Utils/Readme/Editor/ReadmeEditor.cs.meta
Normal file
10
Assets/FlatKit/Utils/Readme/Editor/ReadmeEditor.cs.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd43e6c7d1ad4837a2f833343780f72b
|
||||
timeCreated: 1620541863
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 143368
|
||||
packageName: 'Flat Kit: Toon Shading and Water'
|
||||
packageVersion: 4.9.8
|
||||
assetPath: Assets/FlatKit/Utils/Readme/Editor/ReadmeEditor.cs
|
||||
uploadId: 834448
|
||||
Reference in New Issue
Block a user