Added Unity project files

This commit is contained in:
2026-06-07 16:58:24 +01:00
parent 3cc05d260b
commit 23bbcab156
3942 changed files with 453676 additions and 0 deletions

View File

@ -0,0 +1,74 @@

using System.IO;
using UdonSharp.Compiler;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace UdonSharpEditor
{
public class UdonSharpAssemblyDefinition : ScriptableObject
{
public AssemblyDefinitionAsset sourceAssembly;
[MenuItem("Assets/Create/U# Assembly Definition", false, 98)]
private static void CreateAssemblyDefinition()
{
UdonSharpAssemblyDefinition newAssemblyDefinition = CreateInstance<UdonSharpAssemblyDefinition>();
string folderPath = "Assets/";
if (Selection.activeObject != null)
{
string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);
folderPath = assetPath;
if (Selection.activeObject.GetType() != typeof(UnityEditor.DefaultAsset))
{
folderPath = Path.GetDirectoryName(folderPath);
}
if (Selection.activeObject is AssemblyDefinitionAsset asmDef)
{
newAssemblyDefinition.sourceAssembly = asmDef;
folderPath = Path.Combine(folderPath, $"{Path.GetFileNameWithoutExtension(assetPath)}.asset");
}
else
{
folderPath = Path.Combine(folderPath, "AsmDef.asset");
}
}
else if (Selection.assetGUIDs.Length > 0)
{
folderPath = Path.Combine(AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]), "AsmDef.asset");
}
folderPath = folderPath.Replace('\\', '/');
ProjectWindowUtil.CreateAsset(newAssemblyDefinition, folderPath);
}
}
[CustomEditor(typeof(UdonSharpAssemblyDefinition))]
internal class UdonSharpAssemblyDefinitionEditor : Editor
{
private SerializedProperty _assetProp;
private void OnEnable()
{
_assetProp = serializedObject.FindProperty("sourceAssembly");
}
public override void OnInspectorGUI()
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.ObjectField(_assetProp);
if (EditorGUI.EndChangeCheck())
{
serializedObject.ApplyModifiedProperties();
CompilationContext.ResetAssemblyCaches();
}
}
}
}