コード例 #1
0
        //---------------------------------------------------------------------
        void Start()
        {
#if !UNITY_EDITOR
            //CasinosContext.Instance.AddLog("OpenInstall.RegisterWakeupHandler(_onWakeupFinish)");
            Debug.Log("RegisterWakeupHandler, GetInstall");
            var openinstall = GetComponent <io.openinstall.unity.OpenInstall>();
            openinstall.RegisterWakeupHandler(_onWakeupFinish);
            openinstall.GetInstall(60, _onGetInstallFinish);
            //openinstall.ReportRegister();
            //openinstall.ReportEffectPoint("aaa", 1);
#endif

            bool force_use_resouceslaunch = false;
            bool force_use_dataoss        = false;

#if UNITY_EDITOR
            EditorCfgUserSettingsCopy cfg_usersettings = null;
            string p  = Path.Combine(Environment.CurrentDirectory, "./Assets/SettingsUser/");
            var    di = new DirectoryInfo(p);
            string path_settingsuser = di.FullName;

            string full_filename = Path.Combine(path_settingsuser, StringDef.FileEditorUserSettings);
            if (File.Exists(full_filename))
            {
                using (StreamReader sr = File.OpenText(full_filename))
                {
                    string s = sr.ReadToEnd();
                    cfg_usersettings = JsonUtility.FromJson <EditorCfgUserSettingsCopy>(s);
                }
            }

            if (cfg_usersettings != null)
            {
                force_use_resouceslaunch = cfg_usersettings.ForceUseDirResourcesLaunch;
                force_use_dataoss        = cfg_usersettings.ForceUseDirDataOss;
            }

            //string info = string.Format("ForceUseDirResourcesLaunch={0}, ForceUseDirDataOss={1}",
            //    force_use_resouceslaunch, force_use_dataoss);
            //Debug.Log(info);
            //Debug.Log("PersistentDataPath=" + Application.persistentDataPath);
#endif

            Context = new CasinosContext(force_use_resouceslaunch, force_use_dataoss);
            Context.Launch();
        }
コード例 #2
0
ファイル: MbMain.cs プロジェクト: asd540578/CasinosClient
        //---------------------------------------------------------------------
        void Awake()
        {
            bool force_use_resouceslaunch = false;
            bool force_use_dataoss        = false;

#if UNITY_EDITOR
            EditorCfgUserSettingsCopy cfg_usersettings = null;
            string p  = Path.Combine(Environment.CurrentDirectory, "./Assets/SettingsUser/");
            var    di = new DirectoryInfo(p);
            string path_settingsuser = di.FullName;

            string full_filename = Path.Combine(path_settingsuser, StringDef.FileEditorUserSettings);
            if (File.Exists(full_filename))
            {
                using (StreamReader sr = File.OpenText(full_filename))
                {
                    string s = sr.ReadToEnd();
                    cfg_usersettings = JsonUtility.FromJson <EditorCfgUserSettingsCopy>(s);
                }
            }

            if (cfg_usersettings != null)
            {
                force_use_resouceslaunch = cfg_usersettings.ForceUseDirResourcesLaunch;
                force_use_dataoss        = cfg_usersettings.ForceUseDirDataOss;
            }

            string info = string.Format("ForceUseDirResourcesLaunch={0}, ForceUseDirDataOss={1}",
                                        force_use_resouceslaunch, force_use_dataoss);
            Debug.Log(info);
            Debug.Log("PersistentDataPath=" + Application.persistentDataPath);
#endif

            Context = new CasinosContext(force_use_resouceslaunch, force_use_dataoss);
            Context.Launch();
        }
コード例 #3
0
        //---------------------------------------------------------------------
        void _launch()
        {
            string path_dll = Application.persistentDataPath + "/Launch/Cs/";

#if UNITY_EDITOR
            // 检测Script.CSharp.dll是否存在,如不存在则给出提示
#endif

            byte[] dll = File.ReadAllBytes(path_dll + "Script.dll");
            MsScriptDll = new MemoryStream(dll);

            if (LoadPdb)
            {
                byte[] pdb = File.ReadAllBytes(path_dll + "Script.pdb");
                MsScriptPdb = new MemoryStream(pdb);
            }

            AppDomain.LoadAssembly(MsScriptDll, MsScriptPdb, new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider());

            // 跨域继承适配器注册
            AppDomain.RegisterCrossBindingAdaptor(new CoroutineAdapter());
            AppDomain.RegisterCrossBindingAdaptor(new MonoBehaviourAdapter());

            // 委托Action注册
            AppDomain.DelegateManager.RegisterMethodDelegate <object>();
            AppDomain.DelegateManager.RegisterMethodDelegate <string>();
            AppDomain.DelegateManager.RegisterMethodDelegate <int, string>();
            AppDomain.DelegateManager.RegisterMethodDelegate <List <string> >();
            AppDomain.DelegateManager.RegisterMethodDelegate <AssetBundle>();
            AppDomain.DelegateManager.RegisterMethodDelegate <Texture>();
            AppDomain.DelegateManager.RegisterMethodDelegate <ushort, byte[]>();
            AppDomain.DelegateManager.RegisterMethodDelegate <FairyGUI.EventContext>();
            AppDomain.DelegateManager.RegisterMethodDelegate <FairyGUI.GTweener>();
            AppDomain.DelegateManager.RegisterMethodDelegate <int, FairyGUI.GObject>();
            AppDomain.DelegateManager.RegisterMethodDelegate <Int32, cn.sharesdk.unity3d.ResponseState, cn.sharesdk.unity3d.PlatformType, Hashtable>();

            AppDomain.DelegateManager.RegisterDelegateConvertor <cn.sharesdk.unity3d.ShareSDK.EventHandler>((act) =>
            {
                return(new cn.sharesdk.unity3d.ShareSDK.EventHandler((reqID, state, type, data) =>
                {
                    ((Action <Int32, cn.sharesdk.unity3d.ResponseState, cn.sharesdk.unity3d.PlatformType, Hashtable>)act)(reqID, state, type, data);
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback0>((action) =>
            {
                return(new FairyGUI.EventCallback0(() =>
                {
                    ((Action)action)();
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.EventCallback1>((action) =>
            {
                return(new FairyGUI.EventCallback1((context) =>
                {
                    ((Action <FairyGUI.EventContext>)action)(context);
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.GTweenCallback>((action) =>
            {
                return(new FairyGUI.GTweenCallback(() =>
                {
                    ((Action)action)();
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.GTweenCallback1>((action) =>
            {
                return(new FairyGUI.GTweenCallback1((a) =>
                {
                    ((Action <FairyGUI.GTweener>)action)(a);
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.ListItemRenderer>((action) =>
            {
                return(new FairyGUI.ListItemRenderer((a, b) =>
                {
                    ((Action <int, FairyGUI.GObject>)action)(a, b);
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.PlayCompleteCallback>((action) =>
            {
                return(new FairyGUI.PlayCompleteCallback(() =>
                {
                    ((Action)action)();
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.TimerCallback>((action) =>
            {
                return(new FairyGUI.TimerCallback((a) =>
                {
                    ((Action <object>)action)(a);
                }));
            });

            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.TransitionHook>((action) =>
            {
                return(new FairyGUI.TransitionHook(() =>
                {
                    ((Action)action)();
                }));
            });

            // 委托Function注册
            AppDomain.DelegateManager.RegisterFunctionDelegate <Dictionary <string, string> >();

            AppDomain.DelegateManager.RegisterFunctionDelegate <FairyGUI.GLoader>();
            AppDomain.DelegateManager.RegisterDelegateConvertor <FairyGUI.UIObjectFactory.GLoaderCreator>((func) =>
            {
                return(new FairyGUI.UIObjectFactory.GLoaderCreator(() =>
                {
                    return ((Func <FairyGUI.GLoader>)func)();
                }));
            });

            AppDomain.DelegateManager.RegisterFunctionDelegate <ILRuntime.Runtime.Intepreter.ILTypeInstance, bool>();
            AppDomain.DelegateManager.RegisterDelegateConvertor <Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance> >((act) =>
            {
                return(new Predicate <ILRuntime.Runtime.Intepreter.ILTypeInstance>((obj) =>
                {
                    return ((Func <ILRuntime.Runtime.Intepreter.ILTypeInstance, bool>)act)(obj);
                }));
            });

            // 值类型绑定
            AppDomain.RegisterValueTypeBinder(typeof(Quaternion), new QuaternionBinder());
            AppDomain.RegisterValueTypeBinder(typeof(Vector2), new Vector2Binder());
            AppDomain.RegisterValueTypeBinder(typeof(Vector3), new Vector3Binder());

            // CLR绑定
            LitJson.JsonMapper.RegisterILRuntimeCLRRedirection(AppDomain);
            ILRuntime.Runtime.Generated.CLRBindings.Initialize(AppDomain);

            string platform  = "Android";
            bool   is_editor = false;
#if UNITY_STANDALONE_WIN
            platform = "PC";
#elif UNITY_ANDROID && UNITY_EDITOR
            platform = "Android";
#elif UNITY_ANDROID
            platform = "Android";
#elif UNITY_IPHONE
            platform = "iOS";
#endif

#if UNITY_EDITOR
            is_editor = true;
            AppDomain.DebugService.StartDebugService(56000);
#else
            is_editor = false;
#endif

            bool is_editor_debug = false;
#if UNITY_EDITOR
            EditorCfgUserSettingsCopy cfg_usersettings = null;
            string p  = Path.Combine(Environment.CurrentDirectory, "./Assets/SettingsUser/");
            var    di = new DirectoryInfo(p);
            string path_settingsuser = di.FullName;

            string full_filename = Path.Combine(path_settingsuser, StringDef.FileEditorUserSettings);
            if (File.Exists(full_filename))
            {
                using (StreamReader sr = File.OpenText(full_filename))
                {
                    string s = sr.ReadToEnd();
                    cfg_usersettings = JsonUtility.FromJson <EditorCfgUserSettingsCopy>(s);
                }
            }

            if (cfg_usersettings != null)
            {
                is_editor_debug = cfg_usersettings.IsEditorDebug;
            }
#endif

            AppDomain.Invoke("Cs.Main", "Create", null, new object[] { platform, is_editor, is_editor_debug });
        }