[Add] VContainer

This commit is contained in:
2026-04-07 04:51:37 +07:00
parent 76562726ec
commit 4f9b878775
193 changed files with 8036 additions and 0 deletions
@@ -0,0 +1,47 @@
using System;
using UnityEngine;
namespace VContainer.Unity
{
[Serializable]
public struct ParentReference : ISerializationCallbackReceiver
{
[SerializeField]
public string TypeName;
[NonSerialized]
public LifetimeScope Object;
public Type Type { get; private set; }
ParentReference(Type type)
{
Type = type;
TypeName = type.FullName;
Object = null;
}
void ISerializationCallbackReceiver.OnBeforeSerialize()
{
TypeName = Type?.FullName;
}
void ISerializationCallbackReceiver.OnAfterDeserialize()
{
if (!string.IsNullOrEmpty(TypeName))
{
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
Type = assembly.GetType(TypeName);
if (Type != null)
break;
}
}
}
public static ParentReference Create<T>() where T : LifetimeScope
{
return new ParentReference(typeof(T));
}
}
}