public static void InitUIRoot() { GameObject rootCanvas = ResourceManager.GetGameObject(URLConst.GetUI("UIRoot")); Transform canvas = rootCanvas.transform.FindChild("UICanvas"); GameObject tips = rootCanvas.transform.FindChild("TipsLayer").gameObject; QuickTips.InitQuickTipsLayer(tips, 100); GameConst.auto = rootCanvas.transform.FindChild("auto").gameObject; UIEventHandlerBase.AddListener(GameConst.auto, UIEventType.ON_POINTER_CLICK, delegate(GameObject obj, BaseEventData evn) { ProtoReq.cancelAuto(); }); GameConst.auto.SetActive(false); AlertMgr.Instance.Init(rootCanvas.transform.FindChild("Alert").gameObject); AlertMgr.Instance._alert.SetActive(false); rootCanvas.SetActive(true); rootCanvas.transform.localScale = Vector3.one; GameObject.DontDestroyOnLoad(rootCanvas); GameObject eventSystem = GameObject.Find("EventSystem"); if (eventSystem == null) { eventSystem = new GameObject("EventSystem"); eventSystem.AddComponent <EventSystem>(); eventSystem.AddComponent <StandaloneInputModule>(); eventSystem.AddComponent <TouchInputModule>(); } GameObject.DontDestroyOnLoad(eventSystem); }
public BattlePanelView() { GameObject UIRootCanvas = GameObject.Find("UIRootCanvas"); // GameObject UICamera = UIRootCanvas.transform.FindChild("UICamera").gameObject; view = ResourceMgr.GetGameObject(URLConst.GetUI(UIType.battle.Name)); view.transform.SetParent(UIRootCanvas.transform); view.transform.localPosition = new Vector3(0, 0, 0); view.transform.localScale = new Vector3(1, 1, 1); m_battleSkillUI = new BattleSkillUI(); GameObject cardbtn = view.transform.FindChild("Image").gameObject; UIEventHandlerBase.AddListener(cardbtn, UIEventType.ON_POINTER_DOWN, delegate(GameObject arg1, BaseEventData arg2){ Debug.Log("point down!!!!!!!!"); // SceneMgr.Instance.GetCurSceneView().addMonster(100101); }); UIEventHandlerBase.AddListener(cardbtn, UIEventType.ON_POINTER_UP, delegate(GameObject arg1, BaseEventData arg2){ Debug.Log("point Up!!!!!!!!"); GameObject m_CurSceneGO = SceneManager.GetActiveScene().GetRootGameObjects()[0]; Vector3 pos = m_CurSceneGO.transform.FindChild("Camera").GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition); // SceneMgr.Instance.GetCurSceneView().addMonster(100101, new Vector3(pos.x, pos.y, 0)); CreateAction action = new CreateAction(pos); LockStepMgr.Instance.AddAction(action); }); }
public void soundPlay(string audioName, float volume = 1) { ResourceManager.Instance.DownLoadBundle(URLConst.GetSound(audioName), delegate(object obj){ Resource resource = ResourceManager.Instance.GetResource(URLConst.GetSound(audioName)); AudioClip audioClip = resource.AudioClip; soundPlayStart(audioClip, audioName, volume); ResourceManager.Instance.DestoryResource(resource.BundlePath, false, false); }, null, ResourceManager.SOUND_PRIORITY); }
private void downLoadJoyStickComplete(object userData) { m_joystick = ResourceMgr.GetGameObject(URLConst.GetUI("UIJoyStick")); m_joystickTransform = m_joystick.GetComponent <RectTransform>(); GameObject uiCanvas = GameObject.Find("UIRootCanvas"); UtilsExtends.SetParentExt(m_joystick, uiCanvas.transform); m_joystickTransform.anchoredPosition = skill1Position; }
public void LoadRes(Action <GameObject, object> loadCompleted = null, bool resetRes = false) { if (resetRes == false) { own.attr.GetDefaultPrefabId(); } m_strURL = URLConst.GetModel(own.attr.prefabId.ToString()); ModelMgr.Instance.GetModel(m_strURL, delegate(GameObject kGO, object kArg) { loadCompleted(kGO, kArg); }); }
public void OnTick(float dt) { if (_isLoadingComplete) { _isLoadingComplete = false; isLoading = false; TickMgr.Instance.RemoveTick(this); Resource resPrefab = ResourceMgr.Instance.GetResource(URLConst.GetScenePrefab(m_sceneId)); m_kScenePrefab = GameObjectExt.Instantiate(resPrefab.MainAsset, true) as GameObject; GameObject.DontDestroyOnLoad(m_kScenePrefab); resPrefab.Destory(false, true); DownLoadCompleteAll(); } }
public void LoadRes(string prefabId, Action <GameObject> OnComplete = null, bool resetRes = false) { _prefabId = prefabId; _strUrl = URLConst.GetModel(_prefabId); ModelMgr.Instance.GetModel(_strUrl, delegate(GameObject kGo, object arg) { _kGO = kGo; _kGO.name = _prefabId + "|" + _roleKey; _transform = _kGO.transform; _isLoaded = true; if (OnComplete != null) { OnComplete(kGo); } LoadResCompleted(); }, null, ResourceManager.DEFAULT_PRIORITY, false); }
public void bgmPlay(string audioName, float volume = 1, bool isLoop = true) { if (GameConst._bigAudio.ContainsKey(audioName)) { playBigBgm(audioName, volume, isLoop); } else { ResourceManager.Instance.DownLoadBundle(URLConst.GetSound(audioName), delegate(object obj) { Resource resource = ResourceManager.Instance.GetResource(URLConst.GetSound(audioName)); AudioClip audioClip = resource.AudioClip; bgmPlayStart(audioClip, audioName, volume, isLoop); ResourceManager.Instance.DestoryResource(resource.BundlePath, false, true); }, null, ResourceManager.SOUND_PRIORITY); } }
public void OnLoadBack(object obj) { base_self = ResourceManager.GetGameObject(URLConst.GetUI(base_name), false); Transform component = base_self.GetComponent <Transform>(); component.gameObject.SetActive(true); component.parent = _root.transform; component.name = base_name; component.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(0, 0, 0); component.GetComponent <RectTransform>().sizeDelta = new Vector2(0, 0); InitPanel(component); startUp(obj); _exist = true; _isLoading = false; AddListener(); }
public void LoadRes(int MonId, Action <GameObject, object> loadCompleted = null, bool resetRes = false) { if (resetRes == false) { own.attr.GetDefaultPrefabId(); } m_strURL = URLConst.GetModel(MonId.ToString()); ModelMgr.Instance.GetModel(m_strURL, delegate(GameObject kGO, object kArg) { m_kGO = kGO; renderers = m_kGO.GetComponentsInChildren <Renderer>(); var transform = m_kGO.transform; own.ReplaceModel(transform); own.SetActive(true); loadCompleted(kGO, kArg); }); }
public GameObject GetSingleUI(UIType uiType) { if (_UIDict.ContainsKey(uiType) == false || _UIDict[uiType] == null) { GameObject UIRootCanvas = GameObject.Find("UIRootCanvas"); // GameObject UICamera = UIRootCanvas.transform.FindChild("UICamera").gameObject; GameObject go = ResourceMgr.GetGameObject(URLConst.GetUI(uiType.Name)); go.transform.SetParent(UIRootCanvas.transform); go.transform.localPosition = new Vector3(0, 0, 0); go.transform.localScale = new Vector3(1, 1, 1); Canvas canvas = go.GetComponent <Canvas>(); // Camera camera = UICamera.GetComponent<Camera>(); canvas.renderMode = RenderMode.ScreenSpaceCamera; // canvas.worldCamera = camera; _UIDict.AddOrReplace(uiType, go); return(go); } return(_UIDict[uiType]); }
public void StartLoading() { string[] realPaths = new string[_strTexName.Length]; for (int i = 0; i < _strTexName.Length; i++) { realPaths[i] = URLConst.GetRunTimeTexture(_strTexName[i]); } Action <object> func = delegate(object data) { for (int i = 0; i < realPaths.Length; i++) { Resource res = ResourceManager.Instance.GetResource(realPaths[i]); Texture tex = res.MainAsset as Texture; _dicRunTimeTexture.Add(_strTexName[i], tex); ResourceManager.Instance.DestoryResource(res.BundlePath, false, true); } }; ResourceManager.Instance.DownLoadBundles(realPaths, func, ResourceManager.DEFAULT_PRIORITY); }
private void InitUGUIMain() { GameObject UIRootCanvas = ResourceMgr.GetGameObject(URLConst.GetUI("UIRootCanvas")); // GameObject UICamera = UIRootCanvas.transform.FindChild("UICamera").gameObject; // GameTools.CanvasCamera = UICamera.GetComponent<Camera>(); // GameTools.UICanvasCamera = UIRootCanvas; UIRootCanvas.SetActive(true); GameObject.DontDestroyOnLoad(UIRootCanvas); GameObject eventSystem = GameObject.Find("EventSystem"); if (eventSystem == null) { eventSystem = new GameObject("EventSystem"); eventSystem.AddComponent <EventSystem>(); eventSystem.AddComponent <StandaloneInputModule>(); GameObject.DontDestroyOnLoad(eventSystem); } }
public void load(object obj) { if (_isLoading) { return; } if (!_exist) { _isLoading = true; ResourceManager.Instance.DownLoadBundle(URLConst.GetUI(base_name), delegate(object objc) { OnLoadBack(objc); }, ResourceManager.UI_PRIORITY); } else { base_self.transform.SetAsLastSibling(); base_self.SetActive(true); startUp(obj); } }
public void Load(SceneVo Vo, Action <GameObject> callBack = null, string[] preloadAssets = null) { if (isLoading) { return; } UILoading.ShowLoading(string.Concat("正在进入", Vo.id, "场景..."), "正在预加载", 0); this.callBack = callBack; this.m_sceneId = Vo.id; SceneMgr.Instance.SceneVo = Vo; isLoading = true; _isLoadingComplete = false; GameObjectExt.Destroy(m_kScenePrefab); // Loadinge string[] sceneURLs; int len = 1; if (preloadAssets == null) { sceneURLs = new string[len]; } else { sceneURLs = new string[len + preloadAssets.Length]; for (int i = 0; i < preloadAssets.Length; i++) { sceneURLs[len + i] = preloadAssets[i]; } } sceneURLs[0] = URLConst.GetScenePrefab(Vo.id); ResourceMgr.Instance.DownLoadBundles( sceneURLs, DownLoadComplete, ResourceMgr.UI_PRIORITY, delegate(Resource res, int listCount, int index) { totalNum++; }); }
public virtual void LoadResByType(ON_LOAD_RES_FINISH fnFinish = null, object kArg = null, bool isPay = false) { string strURL = URLConst.GetEffect(m_prefabId); LoadRes(strURL, fnFinish, kArg); }