修改事件为EventBus

This commit is contained in:
陈思海 2026-03-23 20:20:34 +08:00
parent 919678b811
commit 9da67afe50
9 changed files with 2 additions and 111 deletions

View File

@ -4,7 +4,7 @@ using Unity.IL2CPP.CompilerServices;
namespace AlicizaX
{
public static class EventPublisher
public static class EventBus
{
[Il2CppSetOption(Option.NullChecks, false)]
[Il2CppSetOption(Option.DivideByZeroChecks, false)]

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 634e669ad63f4302acca846ec1a0240a
timeCreated: 1736324891

View File

@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d73cc40a000b40e4949fa532373115b5
timeCreated: 1736324891

View File

@ -1,92 +0,0 @@
using System;
using System.Reflection;
using UnityEngine;
namespace AlicizaX
{
/// <summary>
/// A generic reflection field allows you to get or set a generic (object) value for a property, field, or method.
/// </summary>
[Serializable]
public sealed class GenericReflectionField
{
public enum ReflectionType { Field, Property, Method };
public ReflectionType ReflectType;
public MonoBehaviour Instance;
public string ReflectName;
public bool ReflectDerived;
public bool IsSet => Instance != null;
private FieldInfo fieldInfo = null;
private FieldInfo FieldInfo
{
get
{
if (fieldInfo == null)
fieldInfo = Instance.GetType().GetField(ReflectName, BindingFlags.Public | BindingFlags.Instance);
return fieldInfo;
}
}
private PropertyInfo propertyInfo = null;
private PropertyInfo PropertyInfo
{
get
{
if (propertyInfo == null)
propertyInfo = Instance.GetType().GetProperty(ReflectName, BindingFlags.Public | BindingFlags.Instance);
return propertyInfo;
}
}
private MethodInfo methodInfo = null;
private MethodInfo MethodInfo
{
get
{
if (methodInfo == null)
methodInfo = Instance.GetType().GetMethod(ReflectName, BindingFlags.Public | BindingFlags.Instance);
return methodInfo;
}
}
public object Value
{
get => ReflectType switch
{
ReflectionType.Field => FieldInfo.GetValue(Instance),
ReflectionType.Property => PropertyInfo.GetValue(Instance),
ReflectionType.Method => MethodInfo.Invoke(Instance, new object[0]),
_ => throw new NullReferenceException()
};
set
{
try
{
if (ReflectType == ReflectionType.Field)
{
FieldInfo.SetValue(Instance, value);
}
else if (ReflectType == ReflectionType.Property)
{
PropertyInfo.SetValue(Instance, value);
}
else
{
MethodInfo.Invoke(Instance, new object[] { value });
}
}
catch (Exception exception)
{
throw exception;
}
}
}
}
}

View File

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

View File

@ -13,7 +13,7 @@ namespace AlicizaX.Localization
public static void Publisher(string language)
{
EventPublisher.Publish(new LocalizationChangeEvent(language));
EventBus.Publish(new LocalizationChangeEvent(language));
}
}
}