Exemplo n.º 1
0
        protected void SetBack(bool isShowBackBtn = true)
        {
            GameObject prefab = SingletonMB <ResourceManagerController> .GetInstance().LoadAsset(PathUtil.getUiCommonPath(), "PopPanel");

            if (prefab == null)
            {
                return;
            }
            GameObject backPanel = GameObject.Instantiate(prefab) as GameObject;
            Transform  objTrans  = backPanel.transform;

            objTrans.SetParent(rectTrans);
            objTrans.localScale    = Vector3.one;
            objTrans.localPosition = Vector3.zero;

            RectTransform objRectTrans = objTrans as RectTransform;

            objRectTrans.anchorMin        = new Vector2(0, 0);
            objRectTrans.anchorMax        = new Vector2(1, 1);
            objRectTrans.pivot            = new Vector2(0.5f, 0.5f);
            objRectTrans.anchoredPosition = new Vector2(0, 0);
            objRectTrans.sizeDelta        = new Vector2(0, 0);
            objRectTrans.offsetMin        = new Vector2(0, 0);
            objRectTrans.offsetMax        = new Vector2(0, 0);

            objTrans.SetAsFirstSibling();

            Transform go = objTrans.Find("BackBtn");

            if (null != go)
            {
                go.gameObject.SetActive(isShowBackBtn);
            }
        }
Exemplo n.º 2
0
        public void DestoryModule(string name)
        {
            name = name.ToLower();
            BaseModule module;

            if (!moduleList.ContainsKey(name))
            {
                return;
            }
            module = moduleList[name];
            module.OnExit();
            GameObject.DestroyObject(module.gameObject);
            moduleList.Remove(name);

            SingletonMB <ResourceManagerController> .GetInstance().UnloadAssetBundle(name, true);
        }
Exemplo n.º 3
0
        public void PlayMusic(string name)
        {
            AudioClip ac = null;

            if (soundList.TryGetValue(name, out ac))
            {
                //			audioSource.PlayOneShot(ac);
            }
            else
            {
                string path = PathUtil.getSceneSoundPath(name);//默认是场景音乐
                ac = SingletonMB <ResourceManagerController> .GetInstance().LoadAudioClip(path, name);

                soundList.Add(name, ac);
            }
            audioSource.Stop();
            audioSource.clip = ac;
            audioSource.Play();
        }
        //filename  为配置文件名 除去后缀和路径  比如 equip.json  这里的filename 为 equip
        public static Dictionary <int, BaseConfigInfo> GetConfigInfos(string filename)
        {
            if (configs.ContainsKey(filename))
            {
                return(configs[filename]);
            }

            /*string path ="Assets/data/"+filename + ".json";
             * string jsonstr = File.ReadAllText(path, System.Text.Encoding.UTF8);*/

            string jsonstr = SingletonMB <ResourceManagerController> .GetInstance().LoadData(AssetConst.JsonData, filename);

            Util.onTimeStart();
            //		JSONNode jn = JSON.Parse (jsonstr);
            JsonData jd = JsonMapper.ToObject(jsonstr);

            JsonData items = jd["items"];
            //		JSONArray items = jn["items"].AsArray;
            int count = items.Count;

            if (0 == count)
            {
                return(null);
            }
            //		Util.onTimeStart ();
            Dictionary <int, BaseConfigInfo> cinfos = new Dictionary <int, BaseConfigInfo>(count);

            tempList = new BaseConfigInfo[count];

            //		try
            {
                Type        t      = GetConfigInfoType(filename, count);
                FieldInfo[] fields = t.GetFields();
                FieldInfo   f;
                string      fieldName = string.Empty;
                string      value;
                int         len = fields.Length;
                for (int i = 0; i < count; i++)
                {
                    JsonData item = items[i];
                    //				JSONNode item = items[i];
                    //				string json = "";
                    //				json = JsonMapper.ToJson(item);
                    //				BaseConfigInfo cinfo = GetConfigInfo(filename, json);
                    BaseConfigInfo cinfo = tempList[i];
                    for (int m = 0; m < len; m++)
                    {
                        f         = fields[m];
                        fieldName = f.Name;
                        value     = item[f.Name].ToString();
                        //					value = item[f.Name].Value;
                        f.SetValue(cinfo, Convert.ChangeType(value, f.FieldType));
                    }
                    cinfos.Add(cinfo.id, cinfo);
                }
            }
            //		catch
            //		{
            //			Debuger.Log("解析数据出错 filename:" + filename + "   出错数据内容:" + json);
            //		}
            tempList = null;
            configs.Add(filename, cinfos);
            Util.onTimeEnd(filename);
            return(cinfos);
        }