Files
plugin-library/Assets/12.WeixinMinigame/Runtime/WXRuntimeExtDef.cs
stary 0d6faa56f4
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s
微信小程序编译
2026-04-19 00:16:03 +08:00

146 lines
4.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
#if PLATFORM_WEIXINMINIGAME || PLATFORM_WEBGL || UNITY_EDITOR
namespace WeChatWASM
{
public class WXRuntimeExtDef
{
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void OnWXRuntimeExtDefLoadRuntimeMethod()
{
Init();
}
private static void Init()
{
#if UNITY_2018_1_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_2018_1_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2018_1_OR_NEWER", false);
#endif
#if UNITY_2020_1_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_2020_1_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2020_1_OR_NEWER", false);
#endif
#if UNITY_2021_1_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_2021_1_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2021_1_OR_NEWER", false);
#endif
#if UNITY_2021_2_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_2021_2_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2021_2_OR_NEWER", false);
#endif
#if UNITY_2021_3_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_2021_3_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2021_3_OR_NEWER", false);
#endif
#if UNITY_EDITOR_OSX
WXRuntimeExtEnvDef.SETDEF("UNITY_EDITOR_OSX", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_EDITOR_OSX", false);
#endif
#if UNITY_EDITOR_LINUX
WXRuntimeExtEnvDef.SETDEF("UNITY_EDITOR_LINUX", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_EDITOR_LINUX", false);
#endif
#if UNITY_2020
WXRuntimeExtEnvDef.SETDEF("UNITY_2020", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2020", false);
#endif
#if UNITY_2021
WXRuntimeExtEnvDef.SETDEF("UNITY_2021", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2021", false);
#endif
#if UNITY_2022
WXRuntimeExtEnvDef.SETDEF("UNITY_2022", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2022", false);
#endif
#if UNITY_6000
WXRuntimeExtEnvDef.SETDEF("UNITY_6000", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_6000", false);
#endif
#if UNITY_2022_2_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_2022_2_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_2022_2_OR_NEWER", false);
#endif
#if UNITY_INSTANTGAME
WXRuntimeExtEnvDef.SETDEF("UNITY_INSTANTGAME", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_INSTANTGAME", false);
#endif
#if WEIXINMINIGAME
WXRuntimeExtEnvDef.SETDEF("WEIXINMINIGAME", true);
#else
WXRuntimeExtEnvDef.SETDEF("WEIXINMINIGAME", false);
#endif
#if TUANJIE_2022_3_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("TUANJIE_2022_3_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("TUANJIE_2022_3_OR_NEWER", false);
#endif
#if UNITY_6000_0_OR_NEWER
WXRuntimeExtEnvDef.SETDEF("UNITY_6000_0_OR_NEWER", true);
#else
WXRuntimeExtEnvDef.SETDEF("UNITY_6000_0_OR_NEWER", false);
#endif
#if PLATFORM_WEIXINMINIGAME
WXRuntimeExtEnvDef.SETDEF("PLATFORM_WEIXINMINIGAME", true);
#else
WXRuntimeExtEnvDef.SETDEF("PLATFORM_WEIXINMINIGAME", false);
#endif
#if PLATFORM_WEBGL
WXRuntimeExtEnvDef.SETDEF("PLATFORM_WEBGL", true);
#else
WXRuntimeExtEnvDef.SETDEF("PLATFORM_WEBGL", false);
#endif
RegisterController();
}
private static void RegisterController()
{
// Example:
/*
WXRuntimeExtDef.RegisterAction("xxx", (args) =>
{
#if UNITY_2018
return 1;
#else
return 0;
#endif
});
*/
WXRuntimeExtEnvDef.RegisterAction("Unity.GetObjectInstanceID", (args) =>
{
#if UNITY_2021_3_OR_NEWER
if (args is UnityEngine.Object unityObject)
{
return unityObject.GetInstanceID();
}
#endif
// unityObject.GetInstanceID() would never return 0.
return 0;
});
}
}
}
#endif