浏览代码

Fixed many errors of first import for project + Handling reimport

/main
peeweek 5 年前
当前提交
8a6bdf93
共有 6 个文件被更改,包括 72 次插入8 次删除
  1. 6
      Editor/Discover/DiscoverWindow.cs
  2. 8
      Editor/HierarchyHints/HierarchyHints.cs
  3. 2
      Editor/WelcomeScreen/WelcomeScreen.Setup.cs
  4. 20
      Editor/WelcomeScreen/WelcomeScreen.cs
  5. 33
      Editor/GameplayIngredientsAssetPostprocessor.cs
  6. 11
      Editor/GameplayIngredientsAssetPostprocessor.cs.meta

6
Editor/Discover/DiscoverWindow.cs


if (value != GetShowOnStartup(name)) EditorPrefs.SetBool($"{name}.ShowAtStartup", value);
}
public static void Reload()
{
EditorApplication.update -= ShowAtStartup;
s_StartupDiscoverAssets = null;
InitShowAtStartup();
}
[InitializeOnLoadMethod]
static void InitShowAtStartup()

8
Editor/HierarchyHints/HierarchyHints.cs


{
EditorApplication.hierarchyWindowItemOnGUI -= HierarchyOnGUI;
EditorApplication.hierarchyWindowItemOnGUI += HierarchyOnGUI;
foreach (var kvp in s_Definitions)
{
Contents.AddIcon(kvp.Key, kvp.Value);
}
}
static Dictionary<Type, string> s_Definitions = new Dictionary<Type, string>()

public static GUIContent GetContent(Type t)
{
if (!s_Icons.ContainsKey(t) && s_Definitions.ContainsKey(t))
AddIcon(t,s_Definitions[t]);
return s_Icons[t];
}
}

2
Editor/WelcomeScreen/WelcomeScreen.Setup.cs


}
const string kSettingsAssetPath = "Assets/Resources/GameplayIngredientsSettings.asset";
public const string kSettingsAssetPath = "Assets/Resources/GameplayIngredientsSettings.asset";
static void SettingAssetPage()
{

20
Editor/WelcomeScreen/WelcomeScreen.cs


set { if (value != showOnStartup) EditorPrefs.SetBool(kShowOnStartupPreference, value); }
}
static readonly Texture2D header = (Texture2D)EditorGUIUtility.Load("Packages/net.peeweek.gameplay-ingredients/Editor/WelcomeScreen/welcome-title.png");
static Texture2D header
{
get
{
if (s_Header == null)
s_Header = (Texture2D)EditorGUIUtility.Load("Packages/net.peeweek.gameplay-ingredients/Editor/WelcomeScreen/welcome-title.png");
return s_Header;
}
}
static Texture2D s_Header;
public static void Reload()
{
EditorApplication.update -= ShowAtStartup;
InitShowAtStartup();
}
[InitializeOnLoadMethod]
static void InitShowAtStartup()

}
static void ShowAtStartup()

33
Editor/GameplayIngredientsAssetPostprocessor.cs


using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace GameplayIngredients.Editor
{
public class GameplayIngredientsAssetPostprocessor : AssetPostprocessor
{
static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
{
if (importedAssets.Contains(WelcomeScreen.kSettingsAssetPath))
{
Debug.Log("Imported GameplayIngredientsSettings");
WelcomeScreen.Reload();
}
string[] allDiscovery = AssetDatabase.FindAssets("t:DiscoverAsset");
bool needDiscoveryReload = false;
foreach(var guid in allDiscovery)
{
string path = AssetDatabase.GUIDToAssetPath(guid);
if(importedAssets.Contains(path))
{
needDiscoveryReload = true;
break;
}
}
if (needDiscoveryReload)
DiscoverWindow.Reload();
}
}
}

11
Editor/GameplayIngredientsAssetPostprocessor.cs.meta


fileFormatVersion: 2
guid: a13118b22a04c0d4d95bb500a88e59ab
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存