public override void Start() { DropdownServerList.OnValueChangedAsObservable() .Where(index => index == DropdownServerList.options.Count - 1) .Subscribe(_ => this.onAddGameServer?.Invoke()); ButtonTest.onClick.AddListener(delegate { Toast.Show("Hello @" + Random.Range(0, 10000)); }); btnTestAlert.OnClickAsObservable().Subscribe(_ => { Alert.Show(); }); btnLogin.OnClickAsObservable().Subscribe(_ => { this.onPressLogin?.Invoke(); }); btnScreenTest.OnClickAsObservable().Subscribe(_ => { var core = XCore.GetMainInstance(); var uikit = core.Services.Get <IUIKit>(); uikit.OpenUIAsync("Assets/UI/Test/TestScreen.prefab"); }); }
public static void Start() { Debug.Log("vv~~~"); //open ui var core = XCore.GetMainInstance(); var uikit = core.Services.Get <IUIKit>(); uikit.OpenUIAsync("mainScreen", new MainScreen(), (entity, err) => { if (err != null) { Debug.LogError("Open mainScreen failed:" + err.Message); } }); //load scene //var vfs = core.GetService<IVFS>(); //vfs.LoadSceneAsync("Assets/App/Scenes/App.Main.unity", (scene, err) => //{ // scene.OpenScene(); //}); var scene_req = Assets.LoadSceneAsync("Assets/App/Scenes/App.Main.unity", false); scene_req.ToObservable() .ObserveOnMainThread() .SubscribeOnMainThread() .Subscribe(_ => { Debug.Log("Load Scene Success"); }); }
protected override TreeViewItem BuildRoot() { var root = new TreeViewItem { id = 0, depth = -1, displayName = "Root" }; Dict_Assets_id.Clear(); var allItems = new List <TreeViewItem>(); var root_item = new TreeViewItem { id = 1, depth = 0, displayName = "Editor Simulation Assets" }; allItems.Add(root_item); int counter = 1; var vfs = XCore.GetMainInstance().GetService <IVFSInternal>(); if (!vfs.LoadFromAssetbundle()) { foreach (var asset in vfs.GetAllEditorAsset()) { counter++; allItems.Add(new TreeViewItem { id = counter, depth = 1, displayName = asset.AssetPathLower }); Dict_Assets_id.Add(counter, asset); } } // Utility method that initializes the TreeViewItem.children and .parent for all items. SetupParentsAndChildrenFromDepths(root, allItems); // Return root of the tree return(root); }
public XRuntime() { mCore = XCore.GetMainInstance(); mAssemblyFilePath = Path.Combine(XCore.LocalStorage_TinaX, "xruntime", XRuntimeConst.AssemblyFileName); mSymbolFilePath = Path.Combine(XCore.LocalStorage_TinaX, "runtime", XRuntimeConst.SymbolFileName); mAppDomain = new ILAppDomain(); #if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE) mAppDomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif }
internal static string GetCatLibServiceName(Type type) { if (type is ILRuntimeType || type is ILRuntimeWrapperType) { return(type.FullName); } else { return(XCore.GetMainInstance().Services.CatApplication.Type2Service(type)); } }
/// <summary> /// 获取CatLib中的服务名 /// </summary> /// <param name="field"></param> /// <returns></returns> internal static string GetCatLibServiceName(FieldInfo field) { if (field is ILRuntimeFieldInfo) { return(field.FieldType.FullName); } else { return(XCore.GetMainInstance().Services.CatApplication.Type2Service(field.FieldType)); } }
//参考 https://github.com/CatLib/CatLib.ILRuntime/blob/de7ad644efbb5a41db7a0ba33d4fa22a727c8795/src/ILRuntimeApplication.cs internal static string GetCatLibServiceName(PropertyInfo property) { if (property is ILRuntimePropertyInfo) { return(property.PropertyType.FullName); } else { return(XCore.GetMainInstance().Services.CatApplication.Type2Service(property.PropertyType)); } }
/// <summary> /// 实际切换Stage的内部方法 /// </summary> /// <param name="newStage"></param> private void switchStage(StageControllerBase newStage) { if (m_CurrentStage != null) { if (m_CurrentStage == newStage) { return; } else { var last_stage = m_CurrentStage; #region Exit Event 广播退出事件 XEvent.Call(GameStageEventConst.OnStageExit, new string[] { last_stage.StageName, newStage.StageName }, GameStageEventConst.GameStageEventGroupName); XEvent.Call($"{GameStageEventConst.OnStageExit}{last_stage.StageName}", newStage.StageName, GameStageEventConst.GameStageEventGroupName); #endregion m_CurrentStage.OnExit(newStage.StageName); m_CurrentStage = newStage; Debug.Log($"[{GameStageConst.ServiceName}]{(XCore.GetMainInstance().IsCmnHans() ? "切换Stage:" : "Switch Stage:")}" + $"<color=#{TinaX.Internal.XEditorColorDefine.Color_Normal_Pure_16}>{last_stage.StageName}</color> --> <color=#{TinaX.Internal.XEditorColorDefine.Color_Emphasize_16}>{newStage.StageName}</color>"); newStage.OnEnter(last_stage.StageName); #region Enter Event 广播进入事件 XEvent.Call(GameStageEventConst.OnStageEnter, new string[] { newStage.StageName, last_stage.StageName }, GameStageEventConst.GameStageEventGroupName); XEvent.Call($"{GameStageEventConst.OnStageExit}{newStage.StageName}", last_stage.StageName, GameStageEventConst.GameStageEventGroupName); #endregion //广播切换事件 XEvent.Call(GameStageEventConst.OnStageChanged, new string[] { last_stage.StageName, newStage.StageName }, GameStageEventConst.GameStageEventGroupName); } } else { m_CurrentStage = newStage; bool isHans = XCore.GetMainInstance().IsCmnHans(); Debug.Log($"[{GameStageConst.ServiceName}]{(isHans ? "切换Stage:" : "Switch Stage:")}" + $"<color=#{TinaX.Internal.XEditorColorDefine.Color_Safe_16}>*{(isHans?"空 Stage":"No Stage")}*</color> --> <color=#{TinaX.Internal.XEditorColorDefine.Color_Emphasize_16}>{newStage.StageName}</color>"); newStage.OnEnter(string.Empty); //广播进入事件 XEvent.Call(GameStageEventConst.OnStageEnter, new string[] { newStage.StageName, string.Empty }, GameStageEventConst.GameStageEventGroupName); XEvent.Call($"{GameStageEventConst.OnStageExit}{newStage.StageName}", string.Empty, GameStageEventConst.GameStageEventGroupName); //广播切换事件 XEvent.Call(GameStageEventConst.OnStageChanged, new string[] { string.Empty, newStage.StageName }, GameStageEventConst.GameStageEventGroupName); } }
public XILRT(IAssetService assets) { m_Assets = assets; m_AppDomain = new ILAppDomain(); m_Core = XCore.GetMainInstance(); m_XServices = m_Core.Services; #if DEBUG && (UNITY_EDITOR || UNITY_ANDROID || UNITY_IPHONE) m_AppDomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId; #endif LoadSymbol = XCore.GetMainInstance().DevelopMode; #if UNITY_EDITOR LoadSymbol = true; #endif }
private static object GetLogMessage(object message) { if (_logConfig == null) { _logConfig = XCore.GetMainInstance().Services.Get <IXILRuntime>().DebugLogConfig; } if (_logConfig.EnablePrefix) { return($"{_logConfig.PrefixText}{message}"); } else { return(message); } }
public override async void OnRegister() { base.OnRegister(); var core = XCore.GetMainInstance(); var uikit = core.Services.Get <IUIKit>(); await uikit.OpenUIAsync("Assets/UI/SuperPowerEntry/SuperPowerEntry.prefab", view); m_GameServerProxy = (GameServerProxy)GameFacade.Instance.RetrieveProxy(GameServerProxy.NAME); foreach (var server in m_GameServerProxy.ServerList) { view.AddGameServer(server); } view.SelectFirstGameServer(); view.onAddGameServer = () => OpenAddGameServer(); view.onPressLogin = () => OpenLogin(); }
//object Instance<TService>(object instance); internal static StackObject *Instance_TService_Object(ILIntepreter intp, StackObject *esp, IList <object> mStack, CLRMethod method, bool isNewObj) { var genericArguments = method.GenericArguments; if (genericArguments == null || genericArguments.Length != 1 || method.ParameterCount != 1) { throw new EntryPointNotFoundException(); } var tService = XILUtil.ITypeToService(genericArguments[0]); var ptrOfThisMethod = ILIntepreter.Minus(esp, 1); ptrOfThisMethod = ILIntepreter.GetObjectAndResolveReference(ptrOfThisMethod); var instance = (object)typeof(object).CheckCLRTypes( StackObject.ToObject(ptrOfThisMethod, intp.AppDomain, mStack)); intp.Free(ptrOfThisMethod); return(ILIntepreter.PushObject(ILIntepreter.Minus(esp, 1), mStack, XCore.GetMainInstance().Services.Instance(tService, instance))); }
private void DoILBehaviour() { if (XCore.GetMainInstance().Services.TryGet <IXILRuntime>(out var xil)) { var type = xil.ILRuntimeAppDomain.GetType(ILBehaviourTypeName); if (type == null) { Debug.LogError($"[XIL Component - {ILBehaviourTypeName}:{this.gameObject.name}]Type name is invalid : {ILBehaviourTypeName}", this); return; } if (!type.ReflectionType.IsSubclassOf(typeof(XBehaviour))) { Debug.LogError($"[XIL Component - {ILBehaviourTypeName}:{this.gameObject.name}]Type \"{ILBehaviourTypeName}\" does not inherit from \"TinaX.XComponent.XBehaviour\"", this); return; } var behaviour = xil.CreateInstanceAndInject(type.ReflectionType); this.SetBehaviour(((ILTypeInstance)behaviour).CLRInstance as XBehaviour); } else { Debug.LogError($"[XIL Component - {ILBehaviourTypeName}:{this.gameObject.name}]TinaX.ILRuntime Service not ready. XIL Component cannot startup.", this); } }
//public void SetLuaScript(TextAsset lua_text_asset, ReleaseTextAssetDelegate release_asset_callback) //{ // if (this.LuaScript != null) // { // Debug.LogWarning($"[LuaBehaviour : {this.gameObject.name}] Lua Script already exist."); // return; // } // if (lua_text_asset == null) // { // Debug.LogError($"[LuaBehaviour : {this.gameObject.name}] Set LuaScript Failed. Incoming parameter is empty"); // return; // } // this.LuaScript = lua_text_asset; // InitLuaScript(); // if (mAwaked) // func_awake?.Invoke(); // if (mStarted) // func_start?.Invoke(); // if (mEnabled && this.enabled) // func_enable?.Invoke(); // if (mDisabled && !this.enabled) // func_disable?.Invoke(); // HandleUpdates(); // mAsset_Release_Callback = release_asset_callback; // SetLuaScript_Flag = true; //} //public object[] Invoke(string functionName, params object[] args) //{ // if (scriptData != null) // { // LuaFunction func = scriptData.Get<LuaFunction>(functionName); // if(func != null) // { // return func.Call(args); // } // } // return null; //} //public bool TryInvoke(string functionName, out object[] result, params object[] args) //{ // if (scriptData != null) // { // LuaFunction func = scriptData.Get<LuaFunction>(functionName); // if (func != null) // { // result = func.Call(args); // return true; // } // } // result = null; // return false; //} //public TResult Invoke<TResult>(string functionName) //{ // if(scriptData != null) // { // var func = scriptData.Get<Func<TResult>>(functionName); // if(func != null) // { // return func(); // } // } // return default; //} //public void Invoke<T>(string functionName, T arg1) //{ // if (scriptData != null) // scriptData.Get<Action<T>>(functionName)?.Invoke(arg1); //} private void InitLuaScript() { if (XCore.MainInstance == null || !XCore.GetMainInstance().TryGetService(out m_TSManager) || !XCore.GetMainInstance().TryGetService(out m_TSManagerInternal)) { Debug.LogError("[TS Behaviour] TypeScript Service not ready."); return; } //scriptData = m_TSManagerInternal.LuaVM.NewTable(); //LuaTable meta = m_TSManagerInternal.LuaVM.NewTable(); ////元表,让luaBehaviour可以访问_G //meta.Set("__index", m_TSManager.LuaVM.Global); //scriptData.SetMetaTable(meta); //meta.Dispose(); //scriptData.Set("self", this); ////注入绑定对象 //if(base.UObjectBindInfos != null) //{ // foreach(var item in base.UObjectBindInfos) // { // if (!item.Name.IsNullOrEmpty() & item.Object != null) // scriptData.Set(item.Name, item.Object); // } //} //if(base.TypeBindInfos != null) //{ // foreach(var item in base.TypeBindInfos) // { // if (!item.Name.IsNullOrEmpty()) // { // if (XComponents.TryGetValue(item, out object value)) // scriptData.Set(item.Name, value); // } // } //} //m_TSManagerInternal.LuaVM.DoString(LuaScript.bytes, LuaScript.name, scriptData); //scriptData.Get("OnEnable", out func_enable); //scriptData.Get("OnDisable", out func_disable); //scriptData.Get("Awake", out func_awake); //scriptData.Get("Start", out func_start); //scriptData.Get("OnDestroy", out func_destroy); //scriptData.Get("Update", out func_update); //scriptData.Get("FixedUpdate", out func_fixedupdate); //scriptData.Get("LateUpdate", out func_lateupdate); //scriptData.Get("OnApplicationFocus", out func_applicationFocus); //scriptData.Get("OnApplicationPause", out func_applicationPause); //scriptData.Get("OnApplicationQuit", out func_applicationQuit); //scriptData.Get("OnMessage", out func_message); var init = m_TSManagerInternal.JsEnv.Eval <ModuleInit>($"const m = require('{ModuleName}'); m.init"); if (init != null) { init(this, this.UObjectBindInfos, this.TypeBindInfos); } }
public void OnServiceRegister() { XCore.GetMainInstance().BindSingletonService <ILua, LuaManager>().SetAlias <Internal.ILuaInternal>(); }
public Task <bool> OnInit() { mCore = XCore.GetMainInstance(); return(Task.FromResult(true)); }
protected override TreeViewItem BuildRoot() { // BuildRoot is called every time Reload is called to ensure that TreeViewItems // are created from data. Here we create a fixed set of items. In a real world example, // a data model should be passed into the TreeView and the items created from the model. // This section illustrates that IDs should be unique. The root item is required to // have a depth of -1, and the rest of the items increment from that. var root = new TreeViewItem { id = 0, depth = -1, displayName = "Root" }; //var allItems = new List<TreeViewItem> //{ // new TreeViewItem {id = 1, depth = 0, displayName = "Animals"}, // new TreeViewItem {id = 2, depth = 1, displayName = "Mammals"}, // new TreeViewItem {id = 3, depth = 2, displayName = "Tiger"}, // new TreeViewItem {id = 4, depth = 2, displayName = "Elephant"}, // new TreeViewItem {id = 5, depth = 2, displayName = "Okapi"}, // new TreeViewItem {id = 6, depth = 2, displayName = "Armadillo"}, // new TreeViewItem {id = 7, depth = 1, displayName = "Reptiles"}, // new TreeViewItem {id = 8, depth = 2, displayName = "Crocodile"}, // new TreeViewItem {id = 9, depth = 2, displayName = "Lizard"}, //}; Dict_Bundle_id.Clear(); Dict_Assets_id.Clear(); var allItems = new List <TreeViewItem>(); var root_item = new TreeViewItem { id = 1, depth = 0, displayName = "AssetBundle Assets" }; allItems.Add(root_item); int counter = 1; var vfs = XCore.GetMainInstance().GetService <IVFSInternal>(); if (vfs.LoadFromAssetbundle()) { foreach (var bundle in vfs.GetAllBundle()) { counter++; allItems.Add(new TreeViewItem { id = counter, depth = 1, displayName = bundle.AssetBundleName }); Dict_Bundle_id.Add(counter, bundle); if (bundle.Assets != null && bundle.Assets.Count > 0) { foreach (var asset in bundle.Assets) { counter++; allItems.Add(new TreeViewItem { id = counter, depth = 2, displayName = asset.AssetPathLower }); Dict_Assets_id.Add(counter, asset); } } } } // Utility method that initializes the TreeViewItem.children and .parent for all items. SetupParentsAndChildrenFromDepths(root, allItems); // Return root of the tree return(root); }
public XException GetStartException() { return(XCore.GetMainInstance().GetService <IXRuntimeInternal>().GetStartException()); }
public async Task <XException> Start() { #region config if (mInited) { return(null); } mConfig = XConfig.GetConfig <UIConfig>(UIConst.ConfigPath_Resources); if (mConfig == null) { return(new XException("[TinaX.UIKit] Connot found config file.")); } if (!mConfig.EnableUIKit) { return(null); } if (mConfig.UINameMode == UINameMode.UIGroup) { mCurUIGroup = mConfig.DefaultUIGroup; } else { mUIRootDirLoadPath = mConfig.UIRootDirectoryLoadPath; if (!mUIRootDirLoadPath.IsNullOrEmpty()) { if (mUIRootDirLoadPath.EndsWith("/")) { mUIRootDirLoadPath = mUIRootDirLoadPath.Substring(0, mUIRootDirLoadPath.Length - 1); } mUIRootDirLoadPath_withSlash = mUIRootDirLoadPath + "/"; } } mUINameMode = mConfig.UINameMode; #endregion //Init UIKit GameObjects #region UIKit GameObjects mUIKit_Root_Go = XCore.GetMainInstance().BaseGameObject .FindOrCreateGameObject("UIKit") .SetPosition(new Vector3(-9999, -9999, -9999)); if (mConfig.UseUICamera) { var camera_config = mConfig.UICameraConfig; if (camera_config == null) { camera_config = new UICameraConfig(); } mScreenUICamera = mUIKit_Root_Go.FindOrCreateGameObject("UICamera") .AddComponent <Camera>(); mScreenUICamera.clearFlags = camera_config.clearFlags; mScreenUICamera.backgroundColor = camera_config.backgroundColor; mScreenUICamera.cullingMask = camera_config.cullingMask; mScreenUICamera.orthographic = camera_config.orthographic; mScreenUICamera.orthographicSize = camera_config.orthographicSize; mScreenUICamera.nearClipPlane = camera_config.nearClipPlane; mScreenUICamera.farClipPlane = camera_config.farClipPlane; mScreenUICamera.depth = camera_config.depth; mScreenUICamera.renderingPath = camera_config.renderingPath; mScreenUICamera.targetTexture = camera_config.targetTexture; mScreenUICamera.useOcclusionCulling = camera_config.useOcclusionCulling; mScreenUICamera.allowHDR = camera_config.allowHDR; mScreenUICamera.allowMSAA = camera_config.allowMSAA; } //Default UIRoot refreshUIRoot(0); //EventSystem #if ENABLE_LEGACY_INPUT_MANAGER if (mConfig.AutoCreateEventSystem) { var es_go = GameObjectHelper.FindOrCreateGameObject("EventSystem"); var event_system = es_go.GetComponentOrAdd <UnityEngine.EventSystems.EventSystem>(); event_system.sendNavigationEvents = true; event_system.pixelDragThreshold = 10; var input_module = es_go.GetComponentOrAdd <UnityEngine.EventSystems.StandaloneInputModule>(); } #endif #endregion await Task.Yield(); return(null); }
/// <summary> /// 服务注册 /// </summary> public void OnServiceRegister() { XCore.GetMainInstance().BindSingletonService <IXRuntime, IAppDomain, XRuntime>().SetAlias <IXRuntimeInternal>(); }
/// <summary> /// 服务启动 /// </summary> /// <returns></returns> public Task <bool> OnStart() { return(XCore.GetMainInstance().GetService <IXRuntimeInternal>().Start()); }
public Task OnRestart() { return(XCore.GetMainInstance()?.GetService <IVFSInternal>().OnServiceClose()); }
/// <summary> /// 将IType转为字符串 /// </summary> /// <param name="type">类型</param> /// <returns>字符串</returns> public static string ITypeToService(IType type) { var ilType = type as ILType; return(ilType != null ? ilType.FullName : XCore.GetMainInstance().Services.Type2ServiceName(type.TypeForCLR)); }
public void OnQuit() { _ = XCore.GetMainInstance()?.GetService <IVFSInternal>().OnServiceClose(); }
public void OnServiceRegister() { XCore.GetMainInstance()?.BindSingletonService <IVFS, IAssetService, VFSKit>().SetAlias <IVFSInternal>(); }
//private LuaFunction m_EntryFunc; //private CustomLoadHandlerManager m_CustomLoadHandlerManager = new CustomLoadHandlerManager(); public TypeScriptManager(IAssetService buildInAssets) { m_Assets = buildInAssets; m_Core = XCore.GetMainInstance(); //m_JsVM = new JsEnv(new XTSLoader(buildInAssets, c_InternalLuaSign, )); }
public static void Show(string msg) { var uiKit = XCore.GetMainInstance().GetService <IUIKit>(); uiKit.OpenUIAsync("Assets/UI/Tools/Toast/Toast.prefab", new Toast(msg), ExceptionHandler.EntityException); }
public void OnQuit() { XCore.GetMainInstance().Services.Get <IGameStageInternal>().Close(); }