Initial Commit

This commit is contained in:
jellejurre
2025-07-19 01:03:02 +02:00
commit e7904e3140
304 changed files with 22521 additions and 0 deletions

View File

@@ -0,0 +1,405 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using HarmonyLib;
using System.Reflection;
using System.IO;
using System.Linq;
using Object = UnityEngine.Object;
namespace DreadScripts.PackageProcessor
{
[InitializeOnLoad]
public class ExportPostProcessor
{
#region Patching
private static readonly System.Type packageExportType;
private static readonly System.Type packageTreeGUIType;
private static readonly FieldInfo includeDependenciesField;
private static readonly FieldInfo exportItemsField;
private static readonly MethodInfo refreshListMethod;
private static readonly MethodInfo getTreeItemMethod;
#endregion
#region Constants
private const string PARAM_FOLDERS = "exportDefaultOffFolders";
private const string PARAM_EXTENSIONS = "exportDefaultOffExtensions";
private const string PARAM_TYPES = "exportDefaultOffTypes";
private const string PARAM_ASSETS = "exportDefaultOffAssets";
#endregion
private static PackageProcessorData settings;
private static EditorWindow exporterInstance;
private static object rawItems;
private static ReflectedExportPackageItem[] reflectedItems;
private static bool firstStart = true;
static ExportPostProcessor()
{
packageExportType = GetType("UnityEditor.PackageExport");
packageTreeGUIType = GetType("UnityEditor.PackageExportTreeView+PackageExportTreeViewGUI");
includeDependenciesField = packageExportType.GetField("m_IncludeDependencies", BindingFlags.Instance | BindingFlags.NonPublic);
exportItemsField = packageExportType.GetField("m_ExportPackageItems", BindingFlags.Instance | BindingFlags.NonPublic);
refreshListMethod = GetType("UnityEditor.PackageExportTreeView").GetMethod("ComputeEnabledStateForFolders", BindingFlags.Instance | BindingFlags.NonPublic);
getTreeItemMethod = GetType("UnityEditor.PackageExportTreeView+PackageExportTreeViewItem").GetMethod("get_item", BindingFlags.Instance | BindingFlags.Public);
var harmony = new Harmony("com.dreadscripts.exportpostprocessor.tool");
void QuickPatch(System.Type targetType, string ogMethod, string preMethod = "", string poMethod = "")
{
MethodInfo originalMethod = AccessTools.GetDeclaredMethods(targetType).Find(m => m.Name == ogMethod);
HarmonyMethod prefixMethod = string.IsNullOrEmpty(preMethod) ? null : new HarmonyMethod(typeof(ExportPostProcessor).GetMethod(preMethod, BindingFlags.NonPublic | BindingFlags.Static));
HarmonyMethod postMethod = string.IsNullOrEmpty(poMethod) ? null : new HarmonyMethod(typeof(ExportPostProcessor).GetMethod(poMethod, BindingFlags.NonPublic | BindingFlags.Static));
harmony.Patch(originalMethod, prefixMethod, postMethod);
}
QuickPatch(packageExportType, "ShowExportPackage", null, nameof(ShowExportPost));
QuickPatch(packageExportType, "BuildAssetList", null, nameof(BuildAssetListPost));
QuickPatch(packageExportType, "OnGUI", null, nameof(packageGUIPost));
QuickPatch(packageTreeGUIType, "OnRowGUI", nameof(treeRowGUIPrefix));
}
static void ShowExportPost()
{
settings = PackageProcessorData.instance;
exporterInstance = EditorWindow.GetWindow(packageExportType);
firstStart = true;
if (settings.active)
includeDependenciesField.SetValue(exporterInstance, settings.includeDependencies);
}
static void BuildAssetListPost()
{
GetExportItems();
if (!firstStart || !settings.active) return;
firstStart = false;
List<System.Type> offTypes = new List<System.Type>();
settings.exportDefaultOffTypes.ForEach(t =>
{
if (string.IsNullOrWhiteSpace(t)) return;
System.Type targetType = GetType(t);
if (targetType != null)
offTypes.Add(targetType);
});
foreach (var i in reflectedItems)
{
if (offTypes.Any(t => t == i.type) ||
settings.exportDefaultOffFolders.Any(f => i.assetPath.Contains(f)) ||
settings.exportDefaultOffExtensions.Any(s => s == Path.GetExtension(i.assetPath)) ||
(!i.isFolder && settings.exportDefaultOffAssets.Any(g => g == i.guid)))
i.enabledState = 0;
}
}
static void packageGUIPost()
{
using (new GUILayout.HorizontalScope())
{
if (GUILayout.Button("Modified by Dreadrith#3238", "minilabel"))
Application.OpenURL("https://github.com/Dreadrith/DreadScripts");
GUILayout.FlexibleSpace();
}
}
static ReflectedExportPackageItem reflectedTargetItem;
static void treeRowGUIPrefix(Rect rowRect,UnityEditor.IMGUI.Controls.TreeViewItem tvItem)
{
if (Event.current.type == EventType.ContextClick && rowRect.Contains(Event.current.mousePosition))
{
object targetItem = getTreeItemMethod.Invoke(tvItem, null);
if (targetItem != null)
{
reflectedTargetItem = new ReflectedExportPackageItem(targetItem);
if (!reflectedTargetItem.isFolder)
{
GenericMenu myMenu = new GenericMenu();
myMenu.AddItem(new GUIContent("Toggle Type"), false, new GenericMenu.MenuFunction(ToggleSelectedType));
myMenu.AddSeparator("");
if (!HasSelectedAsset())
myMenu.AddItem(new GUIContent("Exclusions/Add Asset"), false, new GenericMenu.MenuFunction(ExcludeSelectedAsset));
else
myMenu.AddItem(new GUIContent("Exclusions/Remove Asset"), false, new GenericMenu.MenuFunction(IncludeSelectedAsset));
if (!HasSelectedType())
myMenu.AddItem(new GUIContent("Exclusions/Add Type"), false, new GenericMenu.MenuFunction(ExcludeSelectedType));
else
myMenu.AddItem(new GUIContent("Exclusions/Remove Type"), false, new GenericMenu.MenuFunction(IncludeSelectedType));
if (!HasSelectedExtension())
myMenu.AddItem(new GUIContent("Exclusions/Add Extension"), false, new GenericMenu.MenuFunction(ExcludeSelectedExtension));
else
myMenu.AddItem(new GUIContent("Exclusions/Remove Extension"), false, new GenericMenu.MenuFunction(IncludeSelectedExtension));
myMenu.ShowAsContext();
Event.current.Use();
}
else
{
GenericMenu myMenu = new GenericMenu();
if (!HasSelectedFolder())
myMenu.AddItem(new GUIContent("Exclusions/Add Folder"), false, new GenericMenu.MenuFunction(ExcludeSelectedFolder));
else
myMenu.AddItem(new GUIContent("Exclusions/Remove Folder"), false, new GenericMenu.MenuFunction(IncludeSelectedFolder));
myMenu.ShowAsContext();
Event.current.Use();
}
}
else
{
GenericMenu myMenu = new GenericMenu();
myMenu.AddDisabledItem(new GUIContent("Folder not being exported"));
myMenu.ShowAsContext();
Event.current.Use();
}
}
}
static void ToggleSelectedType()
{
List<ReflectedExportPackageItem> targetItems = new List<ReflectedExportPackageItem>();
bool allOn = true;
Iterate(reflectedItems, i =>
{
if (i.type == reflectedTargetItem.type)
{
targetItems.Add(i);
if (i.enabledState == 0)
{
allOn = false;
}
}
});
targetItems.ForEach(i => i.enabledState = allOn ? 0 : 1);
RefreshTreeView();
}
static bool HasExclusion(string property, string value)
{
SerializedObject data = new SerializedObject(PackageProcessorData.instance);
SerializedProperty targetProperty = data.FindProperty(property);
for (int i = 0; i < targetProperty.arraySize; i++)
{
if (targetProperty.GetArrayElementAtIndex(i).stringValue == value)
{
return true;
}
}
return false;
}
static void AddExclusion(string property, string value)
{
SerializedObject data = new SerializedObject(PackageProcessorData.instance);
SerializedProperty targetProperty = data.FindProperty(property);
targetProperty.arraySize++;
targetProperty.GetArrayElementAtIndex(targetProperty.arraySize - 1).stringValue = value;
data.ApplyModifiedPropertiesWithoutUndo();
}
static void RemoveExclusion(string property, string value)
{
SerializedObject data = new SerializedObject(PackageProcessorData.instance);
SerializedProperty targetProperty = data.FindProperty(property);
for (int i = 0; i < targetProperty.arraySize; i++)
{
if (targetProperty.GetArrayElementAtIndex(i).stringValue == value)
{
targetProperty.DeleteArrayElementAtIndex(i);
break;
}
}
data.ApplyModifiedPropertiesWithoutUndo();
}
#region Extension Exclusion
static bool HasSelectedExtension() => HasExclusion(PARAM_EXTENSIONS, Ext(reflectedTargetItem.assetPath));
static void ExcludeSelectedExtension() => AddExclusion(PARAM_EXTENSIONS, Ext(reflectedTargetItem.assetPath));
static void IncludeSelectedExtension() => RemoveExclusion(PARAM_EXTENSIONS, Ext(reflectedTargetItem.assetPath));
#endregion
#region Folder Exclusion
static bool HasSelectedFolder() => HasExclusion(PARAM_FOLDERS, reflectedTargetItem.assetPath);
static void ExcludeSelectedFolder() => AddExclusion(PARAM_FOLDERS, reflectedTargetItem.assetPath);
static void IncludeSelectedFolder() => RemoveExclusion(PARAM_FOLDERS, reflectedTargetItem.assetPath);
#endregion
#region Type Exclusion
static bool HasSelectedType() => PackageProcessorData.instance.exportDefaultOffTypes.Any(t => GetType(t) == reflectedTargetItem.type);
static void ExcludeSelectedType() => AddExclusion(PARAM_TYPES, reflectedTargetItem.type.AssemblyQualifiedName);
static void IncludeSelectedType()
{
SerializedObject data = new SerializedObject(PackageProcessorData.instance);
SerializedProperty targetProperty = data.FindProperty(PARAM_TYPES);
for (int i = 0; i < targetProperty.arraySize; i++)
{
Type currentType = GetType(targetProperty.GetArrayElementAtIndex(i).stringValue);
if (currentType == reflectedTargetItem.type)
{
targetProperty.DeleteArrayElementAtIndex(i);
break;
}
}
data.ApplyModifiedPropertiesWithoutUndo();
}
#endregion
#region Asset Exclusion
static bool HasSelectedAsset() => HasExclusion(PARAM_ASSETS, reflectedTargetItem.guid);
static void ExcludeSelectedAsset() => AddExclusion(PARAM_ASSETS, reflectedTargetItem.guid);
static void IncludeSelectedAsset() => RemoveExclusion(PARAM_ASSETS, reflectedTargetItem.guid);
#endregion
private static string Ext(string path) => Path.GetExtension(path);
private static void GetExportItems()
{
rawItems = exportItemsField.GetValue(exporterInstance);
object[] exportItems = (object[])rawItems;
exportItemsField.SetValue(exporterInstance, exportItems);
reflectedItems = new ReflectedExportPackageItem[exportItems.Length];
for (int i = 0; i < exportItems.Length; i++)
reflectedItems[i] = new ReflectedExportPackageItem(exportItems[i]);
}
private static void RefreshTreeView()
{
refreshListMethod.Invoke(packageExportType.GetField("m_Tree", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(exporterInstance), null);
}
private class ReflectedExportPackageItem
{
private readonly object instance;
public bool isFolder => AssetDatabase.IsValidFolder(assetPath);
private string _assetPath;
public string assetPath
{
get
{
if (string.IsNullOrEmpty(_assetPath))
_assetPath = (string)assetPathField.GetValue(instance);
return _assetPath;
}
}
private bool stateInit;
private int _enabledState;
public int enabledState
{
get
{
if (!stateInit)
return 1;
if (_enabledState == -2)
_enabledState = (int)enabledStateField.GetValue(instance);
return _enabledState;
}
set
{
stateInit = true;
_enabledState = value;
enabledStateField.SetValue(instance, value);
}
}
private string _guid;
public string guid
{
get
{
if (string.IsNullOrEmpty(_guid))
_guid = (string)guidField.GetValue(instance);
return _guid;
}
}
private System.Type _type;
public System.Type type
{
get
{
if (asset && _type == null)
_type = asset.GetType();
return _type;
}
}
private Object _asset;
private bool _assetLoaded;
private Object asset
{
get
{
if (_asset || _assetLoaded) return _asset;
_asset = AssetDatabase.LoadMainAssetAtPath(assetPath);
_assetLoaded = true;
return _asset;
}
}
static FieldInfo assetPathField;
static FieldInfo enabledStateField;
static FieldInfo guidField;
public ReflectedExportPackageItem(object instance)
{
this.instance = instance;
}
[InitializeOnLoadMethod]
static void InitializeFields()
{
System.Type targetType = AccessTools.TypeByName("ExportPackageItem");
assetPathField = targetType.GetField("assetPath", BindingFlags.Public | BindingFlags.Instance);
enabledStateField = targetType.GetField("enabledStatus", BindingFlags.Public | BindingFlags.Instance);
guidField = targetType.GetField("guid", BindingFlags.Public | BindingFlags.Instance);
}
}
private static System.Type GetType(string typeName)
{
System.Type myType = System.Type.GetType(typeName);
if (myType != null)
return myType;
foreach (Assembly assembly in System.AppDomain.CurrentDomain.GetAssemblies())
{
myType = assembly.GetType(typeName);
if (myType != null)
return myType;
}
return null;
}
public static void Iterate<T>(IEnumerable<T> collection, System.Action<T> action)
{
using (IEnumerator<T> myNum = collection.GetEnumerator())
{
while (myNum.MoveNext())
{
action(myNum.Current);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: afc24f4a03a4b5d42a9c8ca0f1c4604e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using UnityEngine;
using UnityEditor;
using Object = UnityEngine.Object;
namespace DreadScripts.PackageProcessor
{
[InitializeOnLoad]
public class ImportPostProcessor
{
private static readonly Harmony harmony;
private static readonly FieldInfo assetPathField;
private static readonly FieldInfo enabledStatusField;
private static readonly FieldInfo isFolderField;
static ImportPostProcessor()
{
harmony = new Harmony("com.dreadscripts.importpostprocessor.tool");
Type packageImportType = GetType("UnityEditor.PackageImport");
Type packageImportItemType = GetType("UnityEditor.ImportPackageItem");
assetPathField = packageImportItemType.GetField("destinationAssetPath", BindingFlags.Public | BindingFlags.Instance);
enabledStatusField = packageImportItemType.GetField("enabledStatus", BindingFlags.Public | BindingFlags.Instance);
isFolderField = packageImportItemType.GetField("isFolder", BindingFlags.Public | BindingFlags.Instance);
QuickPatch(packageImportType, "ShowImportPackage", string.Empty, nameof(ShowImportPackagePost));
}
private static void ShowImportPackagePost(object[] items)
{
foreach (var i in items)
{
string path = (string)assetPathField.GetValue(i) ;
bool isFolder = (bool)isFolderField.GetValue(i);
if (!isFolder && !string.IsNullOrEmpty(path) && (path.EndsWith(".cs") || path.EndsWith(".dll")))
enabledStatusField.SetValue(i, 0);
}
}
private static void QuickPatch(System.Type targetType, string ogMethod, string preMethod = "", string poMethod = "")
{
MethodInfo originalMethod = AccessTools.GetDeclaredMethods(targetType).Find(m => m.Name == ogMethod);
HarmonyMethod prefixMethod = string.IsNullOrEmpty(preMethod) ? null : new HarmonyMethod(typeof(ImportPostProcessor).GetMethod(preMethod, BindingFlags.NonPublic | BindingFlags.Static));
HarmonyMethod postMethod = string.IsNullOrEmpty(poMethod) ? null : new HarmonyMethod(typeof(ImportPostProcessor).GetMethod(poMethod, BindingFlags.NonPublic | BindingFlags.Static));
harmony.Patch(originalMethod, prefixMethod, postMethod);
}
private static System.Type GetType(string typeName)
{
System.Type myType = System.Type.GetType(typeName);
if (myType != null)
return myType;
foreach (Assembly assembly in System.AppDomain.CurrentDomain.GetAssemblies())
{
myType = assembly.GetType(typeName);
if (myType != null)
return myType;
}
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cbdf79a44f36b9b4aaabc6ffa66403b9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace DreadScripts.PackageProcessor
{
[System.Serializable]
public class PackageProcessorData : ScriptableObject
{
private static PackageProcessorData _instance;
public static PackageProcessorData instance
{
get
{
if (!_instance && Exists())
if (_instance = AssetDatabase.LoadAssetAtPath<PackageProcessorData>(SavePath))
return _instance;
_instance = CreateInstance<PackageProcessorData>();
if (!System.IO.Directory.Exists(folderPath))
System.IO.Directory.CreateDirectory(folderPath);
AssetDatabase.CreateAsset(_instance, SavePath);
return _instance;
}
}
private static string _folderPath;
public static string folderPath
{
get
{
if (string.IsNullOrEmpty(_folderPath))
_folderPath = PlayerPrefs.GetString("PackageProcessorDataPath", "Assets/DreadScripts/Saved Data/PackageProcessor");
return _folderPath;
}
set => _folderPath = value;
}
private static string SavePath => folderPath + "/PackageProcessorData.asset";
public bool active = true;
public bool includeDependencies = false;
public List<string> exportDefaultOffExtensions = new List<string>();
public List<string> exportDefaultOffFolders = new List<string>();
public List<string> exportDefaultOffTypes = new List<string>();
public List<string> exportDefaultOffAssets = new List<string>();
public static bool Exists() => System.IO.File.Exists(SavePath);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ed2394df32bc4ff439e376a0a2aa49e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,248 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Object = UnityEngine.Object;
namespace DreadScripts.PackageProcessor
{
public class PackageProcessorWindow : EditorWindow
{
private static SerializedObject settings;
private static SerializedProperty includeDependencies;
private static SerializedProperty active;
private static SerializedProperty exportDefaultOffTypes;
private static SerializedProperty exportDefaultOffFolders;
private static SerializedProperty exportDefaultOffExtensions;
private static SerializedProperty exportDefaultOffAssets;
private static Object targetObject;
private static Object targetFolder;
private static Object targetAsset;
[MenuItem("DreadTools/Utility/Package Processor")]
public static void ShowWindow() => GetWindow<PackageProcessorWindow>(false, "Package Processor Settings", true);
private void OnGUI()
{
settings.Update();
using (new BGColorScope(active.boolValue, Color.green, Color.grey))
active.boolValue = GUILayout.Toggle(active.boolValue, "Active", "toolbarbutton");
using (new EditorGUI.DisabledScope(!active.boolValue))
{
using (new LabelWidthScope(200))
EditorGUILayout.PropertyField(includeDependencies, new GUIContent("Default Include Dependencies"));
DrawListProperty(exportDefaultOffExtensions);
DrawListProperty(exportDefaultOffFolders, FolderPropertyGUI);
DrawListProperty(exportDefaultOffTypes, TypePropertyGUI);
DrawAssetProperty(exportDefaultOffAssets);
}
PackageProcessorData.folderPath = AssetFolderPath(PackageProcessorData.folderPath, "Settings Path", "ExportPostProcessorDataPath");
settings.ApplyModifiedProperties();
}
#region GUI Methods
private void DrawListProperty(SerializedProperty p, Action guiCall = null)
{
using (new GUILayout.VerticalScope("box"))
{
p.isExpanded = EditorGUILayout.Foldout(p.isExpanded, p.displayName);
if (!p.isExpanded) return;
guiCall?.Invoke();
EditorGUI.indentLevel++;
if (GUILayout.Button("+"))
p.arraySize++;
for (int i = p.arraySize-1; i >= 0; i--)
{
using (new GUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(p.GetArrayElementAtIndex(i));
if (GUILayout.Button("X", GUILayout.Width(18)))
p.DeleteArrayElementAtIndex(i);
}
}
EditorGUI.indentLevel--;
}
}
private void TypePropertyGUI()
{
using (new GUILayout.HorizontalScope())
{
targetObject = EditorGUILayout.ObjectField("Add Type Of", targetObject, typeof(Object), true);
EditorGUI.BeginDisabledGroup(!targetObject);
if (GUILayout.Button("Add Type"))
{
exportDefaultOffTypes.arraySize++;
exportDefaultOffTypes.GetArrayElementAtIndex(exportDefaultOffTypes.arraySize - 1).stringValue = targetObject.GetType().AssemblyQualifiedName;
}
EditorGUI.EndDisabledGroup();
}
}
private void FolderPropertyGUI()
{
using (new GUILayout.HorizontalScope())
{
EditorGUI.BeginChangeCheck();
targetFolder = EditorGUILayout.ObjectField("Folder", targetFolder, typeof(Object), true);
if (EditorGUI.EndChangeCheck() && targetFolder)
{
string assetPath = AssetDatabase.GetAssetPath(targetFolder);
if (!AssetDatabase.IsValidFolder(assetPath))
targetFolder = AssetDatabase.LoadMainAssetAtPath(System.IO.Path.GetDirectoryName(assetPath));
}
EditorGUI.BeginDisabledGroup(!targetFolder);
if (GUILayout.Button("Add Folder"))
{
exportDefaultOffFolders.arraySize++;
exportDefaultOffFolders.GetArrayElementAtIndex(exportDefaultOffFolders.arraySize - 1).stringValue = AssetDatabase.GetAssetPath(targetFolder);
}
EditorGUI.EndDisabledGroup();
}
}
private void DrawAssetProperty(SerializedProperty p)
{
using (new GUILayout.VerticalScope("box"))
{
p.isExpanded = EditorGUILayout.Foldout(p.isExpanded, p.displayName);
if (p.isExpanded)
{
using (new GUILayout.HorizontalScope())
{
targetAsset = EditorGUILayout.ObjectField("Add GUID Of", targetAsset, typeof(Object), false);
if (AssetDatabase.IsValidFolder(AssetDatabase.GetAssetPath(targetAsset)))
targetAsset = null;
EditorGUI.BeginDisabledGroup(!targetAsset);
if (GUILayout.Button("Add GUID"))
{
AssetDatabase.TryGetGUIDAndLocalFileIdentifier(targetAsset, out string newGUID, out long _);
exportDefaultOffAssets.arraySize++;
exportDefaultOffAssets.GetArrayElementAtIndex(exportDefaultOffAssets.arraySize - 1).stringValue = newGUID;
}
EditorGUI.EndDisabledGroup();
}
EditorGUI.indentLevel++;
if (GUILayout.Button("+"))
{
p.arraySize++;
}
for (int i = p.arraySize - 1; i >= 0; i--)
{
using (new GUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(p.GetArrayElementAtIndex(i));
if (GUILayout.Button("X", GUILayout.Width(18)))
p.DeleteArrayElementAtIndex(i);
if (GUILayout.Button("?",GUILayout.Width(18)))
{
Object asset = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(p.GetArrayElementAtIndex(i).stringValue));
if (!asset)
{
if (EditorUtility.DisplayDialog("Not Found", "Asset for this GUID was not found. Delete?", "Delete", "Ignore"))
p.DeleteArrayElementAtIndex(i);
}
else
EditorGUIUtility.PingObject(asset);
}
}
}
EditorGUI.indentLevel--;
}
}
}
private static string AssetFolderPath(string variable, string title, string playerpref, bool isPlayerPrefs = true)
{
using (new GUILayout.HorizontalScope())
{
using (new EditorGUI.DisabledScope(true))
EditorGUILayout.TextField(title, variable);
if (GUILayout.Button("...", GUILayout.Width(30)))
{
var dummyPath = EditorUtility.OpenFolderPanel(title, AssetDatabase.IsValidFolder(variable) ? variable : "Assets", string.Empty);
if (string.IsNullOrEmpty(dummyPath))
return variable;
string newPath = FileUtil.GetProjectRelativePath(dummyPath);
if (!newPath.StartsWith("Assets"))
{
Debug.LogWarning("New Path must be a folder within Assets!");
return variable;
}
variable = newPath;
if (isPlayerPrefs) PlayerPrefs.SetString(playerpref, variable);
else EditorPrefs.SetString(playerpref, variable);
}
}
return variable;
}
#endregion
private void OnEnable()
{
if (settings == null)
{
settings = new SerializedObject(PackageProcessorData.instance);
includeDependencies = settings.FindProperty("includeDependencies");
active = settings.FindProperty("active");
exportDefaultOffTypes = settings.FindProperty("exportDefaultOffTypes");
exportDefaultOffFolders = settings.FindProperty("exportDefaultOffFolders");
exportDefaultOffExtensions = settings.FindProperty("exportDefaultOffExtensions");
exportDefaultOffAssets = settings.FindProperty("exportDefaultOffAssets");
}
}
#region Scope Classes
public class LabelWidthScope : System.IDisposable
{
private readonly float originalWidth;
public LabelWidthScope(float newWidth)
{
originalWidth = EditorGUIUtility.labelWidth;
EditorGUIUtility.labelWidth = newWidth;
}
public void Dispose() => EditorGUIUtility.labelWidth = originalWidth;
}
public class BGColorScope : System.IDisposable
{
private readonly Color originalColor;
public BGColorScope(bool active, Color activeColor, Color inactiveColor)
{
originalColor = GUI.backgroundColor;
GUI.backgroundColor = active ? activeColor : inactiveColor;
}
public void Dispose() => GUI.backgroundColor = originalColor;
}
#endregion
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 43224e74da76e8a4ca25914ed1364442
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
{
"name": "com.dreadrith.packageprocessor.Editor",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b94789d11fa32064c84634c99b5a21bd
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: