Skip to content

Commit

Permalink
Upgrade Unity-2018.3
Browse files Browse the repository at this point in the history
  • Loading branch information
halak committed Jan 13, 2019
1 parent 77e539c commit 364f856
Show file tree
Hide file tree
Showing 1,421 changed files with 1,466 additions and 1,391 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.vs/
bin/
obj/
Temp/
Library/
Logs/
Temp/
icons/original/
*.sln
*.csproj
51 changes: 46 additions & 5 deletions Assets/Editor/IconMiner.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEngine;
Expand Down Expand Up @@ -50,6 +51,10 @@ private static void ExportIcons()
[MenuItem("Unity Editor Icons/Generate README.md %g", priority = -1000)]
private static void GenerateREADME()
{
var guidMaterial = new Material(Shader.Find("Unlit/Texture"));
var guidMaterialId = "Assets/Editor/GuidMaterial.mat";
AssetDatabase.CreateAsset(guidMaterial, guidMaterialId);

EditorUtility.DisplayProgressBar("Generate README.md", "Generating...", 0.0f);
try
{
Expand All @@ -59,17 +64,29 @@ private static void GenerateREADME()

readmeContents.AppendLine($"Unity Editor Built-in Icons");
readmeContents.AppendLine($"==============================");
readmeContents.AppendLine($"Unity version: {Application.unityVersion}");
readmeContents.AppendLine($"Icons what can load using `EditorGUIUtility.IconContent`");
readmeContents.AppendLine();
readmeContents.AppendLine($"| Icon | Name |");
readmeContents.AppendLine($"|------|------|");
readmeContents.AppendLine($"File ID");
readmeContents.AppendLine($"-------------");
readmeContents.AppendLine($"You can change script icon by file id");
readmeContents.AppendLine($"1. Open `*.cs.meta` in Text Editor");
readmeContents.AppendLine($"2. Modify line `icons: {{instanceID: 0}}` to `icons: {{fileID: <FILE ID>, guid: 0000000000000000d000000000000000, type: 0}}`");
readmeContents.AppendLine($"3. Save and focus Unity Editor");
readmeContents.AppendLine();
readmeContents.AppendLine($"| Icon | Name | File ID |");
readmeContents.AppendLine($"|------|------|---------|");

foreach (var assetName in EnumerateIcons(editorAssetBundle, iconsPath))
var assetNames = EnumerateIcons(editorAssetBundle, iconsPath).ToArray();
for (var i = 0; i < assetNames.Length; i++)
{
var assetName = assetNames[i];
var icon = editorAssetBundle.LoadAsset<Texture2D>(assetName);
if (icon == null)
continue;

EditorUtility.DisplayProgressBar("Generate README.md", $"Generating... ({i + 1}/{assetNames.Length})", (float)i / assetNames.Length);

var readableTexture = new Texture2D(icon.width, icon.height, icon.format, icon.mipmapCount > 1);

Graphics.CopyTexture(icon, readableTexture);
Expand All @@ -81,8 +98,14 @@ private static void GenerateREADME()
var iconPath = Path.Combine(folderPath, icon.name + ".png");
File.WriteAllBytes(iconPath, readableTexture.EncodeToPNG());

//
guidMaterial.mainTexture = icon;
EditorUtility.SetDirty(guidMaterial);
AssetDatabase.SaveAssets();
var fileId = GetFileId(guidMaterialId);

var escapedUrl = iconPath.Replace(" ", "%20").Replace('\\', '/');
readmeContents.AppendLine($"| ![]({escapedUrl}) | `{icon.name}` |");
readmeContents.AppendLine($"| ![]({escapedUrl}) | `{icon.name}` | `{fileId}` |");
}

File.WriteAllText("README.md", readmeContents.ToString());
Expand All @@ -92,6 +115,7 @@ private static void GenerateREADME()
finally
{
EditorUtility.ClearProgressBar();
AssetDatabase.DeleteAsset(guidMaterialId);
}
}

Expand All @@ -109,6 +133,19 @@ private static IEnumerable<string> EnumerateIcons(AssetBundle editorAssetBundle,
}
}

private static string GetFileId(string proxyAssetPath)
{
var serializedAsset = File.ReadAllText(proxyAssetPath);
var index = serializedAsset.IndexOf("_MainTex:", StringComparison.Ordinal);
if (index == -1)
return string.Empty;

const string FileId = "fileID:";
var startIndex = serializedAsset.IndexOf(FileId, index) + FileId.Length;
var endIndex = serializedAsset.IndexOf(',', startIndex);
return serializedAsset.Substring(startIndex, endIndex - startIndex).Trim();
}

private static AssetBundle GetEditorAssetBundle()
{
var editorGUIUtility = typeof(EditorGUIUtility);
Expand All @@ -121,6 +158,9 @@ private static AssetBundle GetEditorAssetBundle()

private static string GetIconsPath()
{
#if UNITY_2018_3_OR_NEWER
return UnityEditor.Experimental.EditorResources.iconsPath;
#else
var assembly = typeof(EditorGUIUtility).Assembly;
var editorResourcesUtility = assembly.GetType("UnityEditorInternal.EditorResourcesUtility");

Expand All @@ -129,6 +169,7 @@ private static string GetIconsPath()
BindingFlags.Static | BindingFlags.Public);

return (string)iconsPathProperty.GetValue(null, new object[] { });
#endif
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/Editor/IconMiner.cs.meta

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

35 changes: 0 additions & 35 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
{
"dependencies": {
"com.unity.ads": "2.0.8",
"com.unity.analytics": "2.0.16",
"com.unity.package-manager-ui": "1.9.11",
"com.unity.purchasing": "2.0.3",
"com.unity.textmeshpro": "1.2.4",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
m_EditorVersion: 2018.2.4f1
m_EditorVersion: 2018.3.0f2
11 changes: 11 additions & 0 deletions ProjectSettings/VFXManager.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!937362698 &1
VFXManager:
m_ObjectHideFlags: 0
m_IndirectShader: {fileID: 0}
m_CopyBufferShader: {fileID: 0}
m_SortShader: {fileID: 0}
m_RenderPipeSettingsPath:
m_FixedTimeStep: 0.016666668
m_MaxDeltaTime: 0.05
Loading

0 comments on commit 364f856

Please sign in to comment.