//场景资源预加载 public void PreloadSceneAsset(string sceneName, ref PreloadResult preloadResult) { this.preloadSceneResult = preloadResult; //获取预加载的场景数据(现在木有,先不处理) List <string> preLoadGOList = null; if (preLoadGOList != null && preLoadGOList.Count > 0) { this.preloadSceneResult.TotalCount += preLoadGOList.Count; } if (this.preloadSceneResult.TotalCount > 0) { //资源加载并生成相应预设 if (preLoadGOList != null) { IResourceMgr resMgr = GameKernel.Get <IResourceMgr>(); foreach (string item in preLoadGOList) { AssetBundleParams abp = new AssetBundleParams(item, typeof(GameObject)); resMgr.LoadNormalObjAsync(abp); } } } else { this.preloadSceneResult = null; } }
public void PreloadSyncAndAsyncAssets(uint sceneId, ref PreloadResult preloadResult) { preloadSyncAndAsyncAssetsResult = preloadResult; IResBinData iResBinData = GameKernel.GetDataCenter().GetResBinData(); //预加载场景资源 }
public static GameObject AddChildToGameObj(GameObject kGoParent, string strPrefabPath) { GameObject obj = null; if (string.IsNullOrEmpty(strPrefabPath) == false) { Object resObj = GameKernel.Get <IDataCenter>().GetDataType <IVLResLoad>().Load(strPrefabPath); if (resObj != null) { obj = Object.Instantiate(resObj) as GameObject; if (kGoParent != null) { obj.transform.parent = kGoParent.transform; obj.transform.localPosition = new Vector3(0f, 0f, 0f); obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; } UIAnchor[] m_Anchors = obj.GetComponentsInChildren <UIAnchor>(); obj.SetActive(true); foreach (UIAnchor a in m_Anchors) { a.uiCamera = kGoParent.GetComponent <Camera>(); } } } return(obj); }
public void LoadScene(uint fromSceneId, uint sceneId, bool showLoading = true, uint taskPreloadSceneId = 0, string loadingTips = "") { #if UNITY_ANDROID && !UNITY_EDITOR //Network.NetChnlDebug.Instance.Debug(); // Network.NetChnlDebug.Instance.Clear(); #endif //Messenger.Broadcast<uint>(MSG_DEFINE.MSG_SCENE_LOAD_START, sceneId); if (mIsLoading == true) { StopCurrent(); } mIsLoading = true; mSceneId = sceneId; mTaskNeedPreloadSceneId = taskPreloadSceneId; //如果有需要,可以加载场景相关配置(TO DO) mSceneConfig = GameKernel.GetDataCenter().GetResBinData().GetSceneConfByID(sceneId); mCurrentSceneName = mSceneConfig.name; if (mSceneConfig != null) { mCurrentScene = mSceneConfig.sceneName; } ConnectProcess(showLoading, loadingTips); StartProcess(); //数据齐全 开始进程 }
private static void RealDestroyGameObject(GameObject go) { if (go == m_kAlwaysToTopGo) { m_kAlwaysToTopGo = null; } Object.Destroy(go); mInstance.Target = null; GameKernel.StartMonoCoroutine(ReleaseResources()); }
private void Init() { DirtyConfArray dirtyArray = GameKernel.GetDataCenter().GetResBinData().GetDirtyConfigArray(); for (int i = 0; i < dirtyArray.items.Count; ++i) { if (dirtyArray.items[i].DirtyWord != string.Empty) { this.AddKey(dirtyArray.items[i].DirtyWord); } } }
public static void TakePhoto(Image im, RectTransform rect) { if (rect != null) { ImgUtil.ca = rect; } if (co != null) { GameKernel.GetInstance().StopCoroutine(co); } co = GameKernel.GetInstance().StartCoroutine(TakephotoIE(im)); }
public static void Dispose() { if (_instance != null) { GameObject go = GameObject.Find(GAME_KERNEL_GO_NAME); if (go) { GameObject.Destroy(go); } _instance = null; } }
void Awake() { Application.targetFrameRate = 100; _instance = this; start += voiceManager.Start; start += treasureManager.Start; start += playerManager.Start; update += treasureManager.Update; update += voiceManager.Update; update += playerManager.Update; destory += treasureManager.Destory; destory += voiceManager.Destory; destory += playerManager.Destory; start(); voiceManager.ChangeAudio(); StartCoroutine(AddEffect()); }
private void Awake() { _instance = this; netManager = new NetManager(); fileManager = new FileManager(); operationManager = new OperationManager(); codingManager = new CodingManager(); objectManager = new ObjectManager(); loginPanelManager = new LoginPanelManager(); mainPanelManager = new MainPanelManager(); userinforPanelManager = new UserinforPanelManager(); noticePanelManager = new NoticePanelManager(); battlePanelManager = new BattlePanelManager(); talentPanelManager = new TalentPanelManager(); onInitEvent(); }
// Use this for initialization void Start() { #if UNITY_ANDROID && !UNITY_EDITOR var www = new WWW(Application.streamingAssetsPath + "/Files.ini"); while (!www.isDone) { } if (null != www.error) { Debug.LogError(www.error); } using (MemoryStream ms = new MemoryStream(www.bytes)) { using (StreamReader sr = new StreamReader(ms)) { while (sr.Peek() >= 0) { string filePath = sr.ReadLine(); var filewww = new WWW(Application.streamingAssetsPath + "/" + filePath); while (!filewww.isDone) { } string targetPath = Path.Combine(Application.persistentDataPath, filePath); string dirPath = targetPath.Substring(0, targetPath.LastIndexOf('/')); if (!Directory.Exists(dirPath)) { Directory.CreateDirectory(dirPath); } File.WriteAllBytes(targetPath, filewww.bytes); } } } GameKernel.OnStart(Application.persistentDataPath); #else GameKernel.OnStart(Application.streamingAssetsPath); #endif DontDestroyOnLoad(this); }
static void CreateInstance() { ReleaseObject(); IResourceMgr resourceMgr = GameKernel.Get <IResourceMgr>(); Object resObj = resourceMgr.LoadNormalObjSync(new AssetBundleParams(mResPath, typeof(GameObject))); if (resObj != null) { GameObject obj = Object.Instantiate(resObj) as GameObject; if (Parent != null) { obj.transform.parent = Parent.transform; obj.transform.localPosition = new Vector3(0f, 0f, 0f); obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; RefreshPanelDepth(obj); } UIAnchor[] m_Anchors = obj.GetComponentsInChildren <UIAnchor>(); obj.SetActive(false); foreach (UIAnchor a in m_Anchors) { a.uiCamera = UICamera; a.gameObject.SetActive(true); } T component = obj.GetComponent <T>(); mInstance.Target = component; mInstance.Target.ReleaseType = mCurReleaseType; IUIComponentContainer container = Container; if (container != null) { container.SetUIComponent <T>(component); } } }
static void Main(string[] args) { var icon = ImageLoader.ImageToBytesStatic(Image.Load <Rgba32>("Data/Images/Misc/ICON_small.png"), false); var cursor = ImageLoader.ImageToBytesStatic(Image.Load <Rgba32>("Data/Images/GUI/Pulse_Glass.png"), false); GameKernel.Init( "Depth of Cold", new OpenTK.Windowing.Common.Input.Image(icon.width, icon.height, icon.ToByteArray()), new OpenTK.Windowing.Common.Input.MouseCursor(0, 0, cursor.width, cursor.height, cursor.ToByteArray()), args); Kernel.GameInit += () => { GameKernel.screenManager.scenarioScreen.textManager.InterfaceCreating += TextManager_InterfaceCreating; GameKernel.screenManager.scenarioScreen.textManager.InterfaceDestroying += TextManager_InterfaceDestroying; GameKernel.screenManager.scenarioScreen.GameStarting += ScenarioScreen_GameStarting; GameKernel.screenManager.GameStart(typeof(MainMenu), typeof(SettingsScreen), typeof(TitleScreen), typeof(MiniMenu), typeof(ExitMenu)); GameKernel.screenManager.AddScreenToGame(typeof(LoadMenu)); }; GameKernel.StartGame(); }
protected override void Init() { kernel = GameKernel.GetInstance(); m_uistacks = new Stack <int>(); m_uicache = new UIBase[(int)UIPageEnum.Max]; m_tips_cache = new List <int>(); sb = new StringBuilder(256); //生成uiroot GameObject temp = ResMgr.LoadGameObject(string.Format(m_UIPath, m_root_tag)); //Debug.Log(string.Format(m_UIPath, m_root_tag)); m_uiRoot = temp.GetComponentInChildren <UIBase>(); m_canvas = m_uiRoot.GetComponent <Canvas>(); //Debug.Log("init the muiRoot"); GameObject.DontDestroyOnLoad(temp); //生成背景遮罩 temp = ResMgr.LoadGameObject(string.Format(m_UIPath, m_mask_tag), m_uiRoot.transform); m_bgMask = temp.GetComponent <UIMask>(); m_bgMask.Hide(); }
public static void Initialize( GameKernel game, GraphicsDeviceManager graphicsManager, SpriteBatch spriteBatch, GameSetupReader gameSetup) { Instance.game = game; Instance.graphicsDevice = game.GraphicsDevice; Instance.graphicsManager = graphicsManager; Instance.spriteBatch = spriteBatch; Instance.window = game.Window; Instance.GameSetup = gameSetup; graphicsManager.SynchronizeWithVerticalRetrace = gameSetup.VSync; Instance.windowResolution = gameSetup.WindowResolution; Instance.borderless = gameSetup.BorderlessOnStartup; Instance.fullscreen = gameSetup.FullscreenOnStartup; Instance.mouseVisible = gameSetup.MouseVisible; Instance.initialized = true; Instance.ReinitScreenProperties(); }
public static void Create() { _instance = new GameObject(GAME_KERNEL_GO_NAME).AddComponent <GameKernel>(); DontDestroyOnLoad(_instance.gameObject); }
//预加载普通资源 public void PreloadAsyncAssets(uint sceneId, ref PreloadResult preloadResult) { //初始化系统 preloadAsyncAssetsResult = preloadResult; IResBinData iResBinData = GameKernel.GetDataCenter().GetResBinData(); //预加载及预热资源 List <string> preLoadObjList = null; List <string> PreloadAndPrehotObjList = null; if (preLoadObjList != null && preLoadObjList.Count > 0) { preloadAsyncAssetsResult.TotalCount += preLoadObjList.Count; } if (PreloadAndPrehotObjList != null && PreloadAndPrehotObjList.Count > 0) { preloadAsyncAssetsResult.TotalCount += PreloadAndPrehotObjList.Count; } if (preloadAsyncAssetsResult.TotalCount > 0) { IResourceMgr resMgr = GameKernel.Get <IResourceMgr>(); /*if (preLoadObjList != null) * { * foreach (string item in preLoadObjList) * { * AssetBundleParams abp = * AssetBundleParamFactory.Create(item); * resMgr.LoadSceneResidentMemoryObjAsync(abp, preloadObjCallBack); * } * } * if (PreloadAndPrehotObjList != null) * { * foreach (string item in PreloadAndPrehotObjList) * { * AssetBundleParams abp = AssetBundleParamFactory.Create(item); * abp.IsPreloadMainAsset = true; * * ResLogger.Log("Prelaod " + abp.path + " " + abp.type); * * resMgr.LoadSceneResidentMemoryObjAsync(abp, preloadObjCallBack); * } * } * * for (int i = 0; i < diffPreloads.Count; i++) * { * if (!string.IsNullOrEmpty(diffPreloads[i])) * { * AssetBundleParams abp = AssetBundleParamFactory.Create(diffPreloads[i]); * abp.IsPreloadMainAsset = true; * * ResLogger.Log("Diff Prelaod " + abp.path + " " + abp.type); * * resMgr.LoadResidentMemoryObjAsync(abp, preloadObjCallBack); * } * }*/ } else { preloadAsyncAssetsResult = null; } }
void initAsset() { preloadResult = null; preloadResult = new PreloadResult(); GameKernel.CreateForInitData(); IResourceMgr resourceMgr = GameKernel.Get <IResourceMgr>(); ResBinData iResBinData = NewResBinDataForPreLoad(); //预加载资源,不需要提前获取mainAsset List <string> residentGoList = iResBinData.GetImmortalAssetList(1); List <string> residentACList = iResBinData.GetImmortalAssetList(3); List <string> residentTexture2DList = iResBinData.GetImmortalAssetList(5); List <string> residentAudioClipList = iResBinData.GetImmortalAssetList(7); List <string> residentAnimClipList = iResBinData.GetImmortalAssetList(9); //预加载资源,需要提前获取mainAsset List <string> residentPreloadGoList = iResBinData.GetImmortalAssetList(2); List <string> residentPreloadACList = iResBinData.GetImmortalAssetList(4); List <string> residentPreloadTexture2DList = iResBinData.GetImmortalAssetList(6); List <string> residentPreloadAudioClipList = iResBinData.GetImmortalAssetList(8); List <string> residentPreloadAnimClipList = iResBinData.GetImmortalAssetList(10); if (residentGoList != null && residentGoList.Count > 0) { this.preloadResult.TotalCount += residentGoList.Count; } if (residentPreloadGoList != null && residentPreloadGoList.Count > 0) { this.preloadResult.TotalCount += residentPreloadGoList.Count; } if (residentACList != null && residentACList.Count > 0) { this.preloadResult.TotalCount += residentACList.Count; } if (residentPreloadACList != null && residentPreloadACList.Count > 0) { this.preloadResult.TotalCount += residentPreloadACList.Count; } if (residentTexture2DList != null && residentTexture2DList.Count > 0) { this.preloadResult.TotalCount += residentTexture2DList.Count; } if (residentPreloadTexture2DList != null && residentPreloadTexture2DList.Count > 0) { this.preloadResult.TotalCount += residentPreloadTexture2DList.Count; } if (residentAudioClipList != null && residentAudioClipList.Count > 0) { this.preloadResult.TotalCount += residentAudioClipList.Count; } if (residentPreloadAudioClipList != null && residentPreloadAudioClipList.Count > 0) { this.preloadResult.TotalCount += residentPreloadAudioClipList.Count; } if (residentAnimClipList != null && residentAnimClipList.Count > 0) { this.preloadResult.TotalCount += residentAnimClipList.Count; } if (residentPreloadAnimClipList != null && residentPreloadAnimClipList.Count > 0) { this.preloadResult.TotalCount += residentPreloadAnimClipList.Count; } if (residentGoList != null) { for (int i = 0; i < residentGoList.Count; i++) { abp = new AssetBundleParams(residentGoList[i], typeof(GameObject)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadGoList != null) { for (int i = 0; i < residentPreloadGoList.Count; i++) { abp = new AssetBundleParams(residentPreloadGoList[i], typeof(GameObject)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentACList != null) { for (int i = 0; i < residentACList.Count; i++) { abp = new AssetBundleParams(residentACList[i], typeof(RuntimeAnimatorController)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadACList != null) { for (int i = 0; i < residentPreloadACList.Count; i++) { abp = new AssetBundleParams(residentPreloadACList[i], typeof(RuntimeAnimatorController)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentTexture2DList != null) { for (int i = 0; i < residentTexture2DList.Count; i++) { abp = new AssetBundleParams(residentTexture2DList[i], typeof(Texture2D)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadTexture2DList != null) { for (int i = 0; i < residentPreloadTexture2DList.Count; i++) { abp = new AssetBundleParams(residentPreloadTexture2DList[i], typeof(Texture2D)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentAudioClipList != null) { for (int i = 0; i < residentAudioClipList.Count; i++) { abp = new AssetBundleParams(residentAudioClipList[i], typeof(AudioClip)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadAudioClipList != null) { for (int i = 0; i < residentPreloadAudioClipList.Count; i++) { abp = new AssetBundleParams(residentPreloadAudioClipList[i], typeof(AudioClip)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentAnimClipList != null) { for (int i = 0; i < residentAnimClipList.Count; i++) { abp = new AssetBundleParams(residentAnimClipList[i], typeof(AnimationClip)); resourceMgr.LoadResidentMemoryObjAsync(abp); } } if (residentPreloadAnimClipList != null) { for (int i = 0; i < residentPreloadAnimClipList.Count; i++) { abp = new AssetBundleParams(residentPreloadAnimClipList[i], typeof(AnimationClip)); abp.IsPreloadMainAsset = true; resourceMgr.LoadResidentMemoryObjAsync(abp); } } ReleaseNewResBinData(); }
private void OnDestroy() { GameKernel.OnQuit(); }
void FixedUpdate() { GameKernel.FixUpdate(); }
private void Update() { GameKernel.Update(); }
private void Awake() { kernel = GameKernel.GetInstance(); kernel.Init(); }