This commit is contained in:
SoulliesOfficial
2025-12-17 04:19:38 -05:00
parent 7c1cb7e8e1
commit d15957c719
4315 changed files with 8260710 additions and 2940 deletions

View File

@@ -0,0 +1,24 @@
using UnityEditor;
using UnityEngine;
namespace GraphicsCat
{
// Allow this attribute to be used on fields only
[System.AttributeUsage(System.AttributeTargets.Field)]
public class AutoLoadAttribute : PropertyAttribute
{
// Store the asset GUID for reliable loading
public string assetGUID;
// Add a constructor that allows a path to be passed in for initial setup.
// The drawer will convert this path to a GUID.
public AutoLoadAttribute(string path)
{
#if UNITY_EDITOR
this.assetGUID = AssetDatabase.AssetPathToGUID(path);
#endif
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 91ff3b2732c536048991e97899a4613a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/Common/AutoLoad/AutoLoadAttribute.cs
uploadId: 820558

View File

@@ -0,0 +1,49 @@
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
namespace GraphicsCat
{
[CustomPropertyDrawer(typeof(AutoLoadAttribute))]
public class AutoLoadDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
AutoLoadAttribute autoLoad = attribute as AutoLoadAttribute;
EditorGUI.PropertyField(position, property, label);
if (property.objectReferenceValue == null)
{
if (!string.IsNullOrEmpty(autoLoad.assetGUID))
{
string assetPath = AssetDatabase.GUIDToAssetPath(autoLoad.assetGUID);
if (!string.IsNullOrEmpty(assetPath))
{
System.Type fieldType = fieldInfo.FieldType;
Object loadedAsset = AssetDatabase.LoadAssetAtPath(assetPath, fieldType);
if (loadedAsset != null)
{
property.objectReferenceValue = loadedAsset;
Debug.Log($"Auto-loaded asset '{loadedAsset.name}' for field '{property.displayName}' using GUID.");
}
else
{
Debug.LogWarning($"AutoLoadDrawer: Failed to load asset with GUID '{autoLoad.assetGUID}'.");
}
}
}
}
if (property.objectReferenceValue != null)
{
string assetPath = AssetDatabase.GetAssetPath(property.objectReferenceValue);
string guid = AssetDatabase.AssetPathToGUID(assetPath);
autoLoad.assetGUID = guid;
}
}
}
}
#endif

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a73153d0825f8f04b991a1086b09ce43
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 328765
packageName: LitPlus - URP Enhanced Lit Shader
packageVersion: 1.0.1
assetPath: Assets/GraphicsCat/Modules/Common/AutoLoad/AutoLoadDrawer.cs
uploadId: 820558