更新
This commit is contained in:
parent
468a6ec694
commit
835434c88e
46
Editor/Misc/EventScriptingDefineSymbols.cs
Normal file
46
Editor/Misc/EventScriptingDefineSymbols.cs
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
using AlicizaX.Editor;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace AlicizaX.Editor
|
||||||
|
{
|
||||||
|
internal static class EventScriptingDefineSymbols
|
||||||
|
{
|
||||||
|
private const string MenuPath = "Tools/AlicizaX/Enable Strict Check";
|
||||||
|
private const string DefineSymbol = "Event_StrictCheck";
|
||||||
|
|
||||||
|
[MenuItem(MenuPath)]
|
||||||
|
private static void ToggleStrictCheck()
|
||||||
|
{
|
||||||
|
bool enabled = IsEnabled();
|
||||||
|
SetEnabled(!enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
[MenuItem(MenuPath, true)]
|
||||||
|
private static bool ToggleStrictCheckValidate()
|
||||||
|
{
|
||||||
|
Menu.SetChecked(MenuPath, IsEnabled());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsEnabled()
|
||||||
|
{
|
||||||
|
return ScriptingDefineSymbols.HasScriptingDefineSymbol(EditorUserBuildSettings.selectedBuildTargetGroup, DefineSymbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
var targetGroup = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
ScriptingDefineSymbols.AddScriptingDefineSymbol(targetGroup, DefineSymbol);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(targetGroup, DefineSymbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log($"[EventKit] Strict Check {(enabled ? "Enabled" : "Disabled")}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Editor/Misc/EventScriptingDefineSymbols.cs.meta
Normal file
3
Editor/Misc/EventScriptingDefineSymbols.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a0f666b24d9c41c4a355f9a9a643928b
|
||||||
|
timeCreated: 1756782190
|
BIN
Plugins/EventSourceGenerator.dll
Normal file
BIN
Plugins/EventSourceGenerator.dll
Normal file
Binary file not shown.
52
Plugins/EventSourceGenerator.dll.meta
Normal file
52
Plugins/EventSourceGenerator.dll.meta
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e0f9fe588fe13b14ca28cddf735a2f0b
|
||||||
|
labels:
|
||||||
|
- RoslynAnalyzer
|
||||||
|
PluginImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 3
|
||||||
|
iconMap: {}
|
||||||
|
executionOrder: {}
|
||||||
|
defineConstraints: []
|
||||||
|
isPreloaded: 0
|
||||||
|
isOverridable: 1
|
||||||
|
isExplicitlyReferenced: 0
|
||||||
|
validateReferences: 1
|
||||||
|
platformData:
|
||||||
|
Any:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
Exclude Editor: 1
|
||||||
|
Exclude Linux64: 0
|
||||||
|
Exclude OSXUniversal: 0
|
||||||
|
Exclude Win: 0
|
||||||
|
Exclude Win64: 0
|
||||||
|
Editor:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
DefaultValueInitialized: true
|
||||||
|
OS: AnyOS
|
||||||
|
Linux64:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
OSXUniversal:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
Win:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
Win64:
|
||||||
|
enabled: 1
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
WindowsStoreApps:
|
||||||
|
enabled: 0
|
||||||
|
settings:
|
||||||
|
CPU: AnyCPU
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
3
Runtime/Event.meta
Normal file
3
Runtime/Event.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 421689177e8f4c58ae0ce91e5ea9f9c3
|
||||||
|
timeCreated: 1736415505
|
36
Runtime/Event/EventRuntimeHandle.cs
Normal file
36
Runtime/Event/EventRuntimeHandle.cs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using Unity.IL2CPP.CompilerServices;
|
||||||
|
|
||||||
|
namespace AlicizaX
|
||||||
|
{
|
||||||
|
public interface IEventArgs { }
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Struct)]
|
||||||
|
public sealed class PrewarmAttribute : Attribute
|
||||||
|
{
|
||||||
|
public int Capacity { get; }
|
||||||
|
public PrewarmAttribute(int capacity) => Capacity = capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Il2CppSetOption(Option.NullChecks, false)]
|
||||||
|
[Il2CppSetOption(Option.DivideByZeroChecks, false)]
|
||||||
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
||||||
|
public readonly struct EventRuntimeHandle
|
||||||
|
{
|
||||||
|
private readonly Action<int,int> _unsubscribe;
|
||||||
|
private readonly int _index;
|
||||||
|
private readonly int _version;
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public EventRuntimeHandle(Action<int,int> unsubscribe, int index, int version)
|
||||||
|
{
|
||||||
|
_unsubscribe = unsubscribe;
|
||||||
|
_index = index;
|
||||||
|
_version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
|
public void Dispose() => _unsubscribe?.Invoke(_index, _version);
|
||||||
|
}
|
||||||
|
}
|
3
Runtime/Event/EventRuntimeHandle.cs.meta
Normal file
3
Runtime/Event/EventRuntimeHandle.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d85feee75c2d4b54bd6b593fe55145d7
|
||||||
|
timeCreated: 1740488369
|
74
Runtime/Event/Il2CppSetOptionAttribute.cs
Normal file
74
Runtime/Event/Il2CppSetOptionAttribute.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Unity.IL2CPP.CompilerServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The code generation options available for IL to C++ conversion.
|
||||||
|
/// Enable or disabled these with caution.
|
||||||
|
/// </summary>
|
||||||
|
public enum Option
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable code generation for null checks.
|
||||||
|
///
|
||||||
|
/// Global null check support is enabled by default when il2cpp.exe
|
||||||
|
/// is launched from the Unity editor.
|
||||||
|
///
|
||||||
|
/// Disabling this will prevent NullReferenceException exceptions from
|
||||||
|
/// being thrown in generated code. In *most* cases, code that dereferences
|
||||||
|
/// a null pointer will crash then. Sometimes the point where the crash
|
||||||
|
/// happens is later than the location where the null reference check would
|
||||||
|
/// have been emitted though.
|
||||||
|
/// </summary>
|
||||||
|
NullChecks = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable code generation for array bounds checks.
|
||||||
|
///
|
||||||
|
/// Global array bounds check support is enabled by default when il2cpp.exe
|
||||||
|
/// is launched from the Unity editor.
|
||||||
|
///
|
||||||
|
/// Disabling this will prevent IndexOutOfRangeException exceptions from
|
||||||
|
/// being thrown in generated code. This will allow reading and writing to
|
||||||
|
/// memory outside of the bounds of an array without any runtime checks.
|
||||||
|
/// Disable this check with extreme caution.
|
||||||
|
/// </summary>
|
||||||
|
ArrayBoundsChecks = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// Enable or disable code generation for divide by zero checks.
|
||||||
|
///
|
||||||
|
/// Global divide by zero check support is disabled by default when il2cpp.exe
|
||||||
|
/// is launched from the Unity editor.
|
||||||
|
///
|
||||||
|
/// Enabling this will cause DivideByZeroException exceptions to be
|
||||||
|
/// thrown in generated code. Most code doesn't need to handle this
|
||||||
|
/// exception, so it is probably safe to leave it disabled.
|
||||||
|
/// </summary>
|
||||||
|
DivideByZeroChecks = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Use this attribute on an assembly, struct, class, method, or property to inform the IL2CPP code conversion utility to override the
|
||||||
|
/// global setting for one of a few different runtime checks.
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
///
|
||||||
|
/// [Il2CppSetOption(Option.NullChecks, false)]
|
||||||
|
/// public static string MethodWithNullChecksDisabled()
|
||||||
|
/// {
|
||||||
|
/// var tmp = new Object();
|
||||||
|
/// return tmp.ToString();
|
||||||
|
/// }
|
||||||
|
/// </summary>
|
||||||
|
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Delegate, Inherited = false, AllowMultiple = true)]
|
||||||
|
public class Il2CppSetOptionAttribute : Attribute
|
||||||
|
{
|
||||||
|
public Option Option { get; private set; }
|
||||||
|
public object Value { get; private set; }
|
||||||
|
|
||||||
|
public Il2CppSetOptionAttribute(Option option, object value)
|
||||||
|
{
|
||||||
|
Option = option;
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
2
Runtime/Event/Il2CppSetOptionAttribute.cs.meta
Normal file
2
Runtime/Event/Il2CppSetOptionAttribute.cs.meta
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 997668ad76a5387428e679240d659155
|
Loading…
Reference in New Issue
Block a user