Exemple #1
0
        /// <summary>
        /// 创建一个UI
        /// </summary>
        /// <param name="_name"></param>
        /// <returns></returns>
        private UI_Base _createUIObject(String _name)
        {
            UnityEngine.Object prefab = null;
#if !GROOT_ASSETBUNDLE_SIMULATION && UNITY_EDITOR
            String path = String.Format("{0}/{1}.prefab", WeiqiApp.UI_PREFAB_ROOT_PATH, _name);
            prefab = AssetDatabase.LoadMainAssetAtPath(path);
            if (prefab == null)
            {
                Utility.Log.Error("[UIManager._create]ui: {0} 不存在!", path);
                return(null);
            }
#else
            Resource_Assetbundle bundle = ResourceManager.Instance.LoadAssetbundleSync(String.Concat("ui/", _name, ".ui"));
            if (bundle.Assetbundle == null)
            {
                Utility.Log.Error("[UIManager._create]ui: {0} 不存在!", _name);
                return(null);
            }
            prefab = bundle.Assetbundle.LoadAsset(_name);
            bundle.Unload(false);
            //prefab = ResourceManager.Instance.LoadUIObject( _name );
#endif
            GameObject ui_object = Instantiate(prefab) as GameObject;
            ui_object.SetActive(false);
            ui_object.name = _name;             //预制创建出来名字中会有(Clone)所以去掉

            // 放置ui到对应的层
            UI_Base ui_base = ui_object.GetComponent <UI_Base>();
            ui_object.transform.SetParent(m_layer_transforms[(Int32)ui_base.Layer], false);

            ui_base.OnLoaded();
            m_loaded_ui.Add(ui_base);
            return(ui_base);
        }
Exemple #2
0
        public override SheetLite OpenSheet(String _sheet_name)
        {
            //Resource_Assetbundle bundle = null;
            //if( m_data_path.CompareTo( WeiqiApp.CONFIG_ROOT_PATH ) == 0 )
            //{
            //	if( _sheet_name.Substring( 0, 3 ).CompareTo( "pre" ) == 0 )
            //		bundle = ResourceManager.Instance.GetResource( string.Format( "{0}/pre_config.cg", m_data_path ) ) as Resource_Assetbundle;
            //	else
            //		bundle = ResourceManager.Instance.GetResource( string.Format( "{0}/config.cg", m_data_path ) ) as Resource_Assetbundle;
            //}
            //else
            //{
            //	String[] array = _sheet_name.Split( '/' );
            //	string language = array[0];
            //	_sheet_name = array[1];
            //	if( _sheet_name.Substring( 0, 3 ).CompareTo( "pre" ) == 0 )
            //		bundle = ResourceManager.Instance.GetResource( string.Format( "{0}/pre_{1}.cg", m_data_path, language ) ) as Resource_Assetbundle;
            //	else
            //		bundle = ResourceManager.Instance.GetResource( string.Format( "{0}/{1}.cg", m_data_path, language ) ) as Resource_Assetbundle;
            //}
            //if ( bundle == null || !bundle.CheckLoaded() )
            //{
            //	Log.Error( "[ResouceManager]: data/config包不存在或没有加载!不能读取配置{0}", _sheet_name );
            //	return null;
            //}
            Resource_Assetbundle bundle = ResourceManager.Instance.LoadAssetbundleSync(string.Format("{0}/{1}.cg", m_data_path, _sheet_name));

            if (bundle == null)
            {
                throw new ExceptionEx("不存在配置文件包: {0}", _sheet_name);
            }
            if (m_data_path.CompareTo(WeiqiApp.LANGUAGES_ROOT_PATH) == 0)
            {
                String[] array = _sheet_name.Split('/');
                _sheet_name = array[1];
            }
            TextAsset asset = bundle.LoadAssetSync(_sheet_name, typeof(TextAsset)) as TextAsset;

            if (asset == null)
            {
                throw new ExceptionEx("配置文件assetbundle中不包含: {0}", _sheet_name);
            }
            try
            {
                SheetLite sheet = new SheetLite();
                sheet = !sheet.Open(_sheet_name, asset.bytes) ? null : sheet;
                bundle.Unload(true);
                return(sheet);
            }
            catch (Exception e)
            {
                Log.Error("[SheetLiteDbAssetBundle]Failed to open sheet {0} \nmsg:  {1}.", _sheet_name, e.Message);
            }
            return(null);
        }
Exemple #3
0
    public static Byte[] GetXmlConfigBytes(String _file_name)
    {
#if !GROOT_ASSETBUNDLE_SIMULATION && UNITY_EDITOR
        String path = String.Format("{0}/{1}.xml", WeiqiApp.CONFIG_ROOT_PATH, _file_name);
        if (!System.IO.File.Exists(path))
        {
            throw new ExceptionEx("本地配置文件 {0} 不存在!", path);
        }

        Byte[] bytes = FileHelper.ReadAllBytesFromFile(path);
        return(bytes);
#else
        Resource_Assetbundle bundle = ResourceManager.Instance.LoadAssetbundleSync(string.Format("{0}/{1}.cg", WeiqiApp.CONFIG_ROOT_PATH, _file_name));
        if (bundle == null)
        {
            throw new ExceptionEx("不存在配置文件包: {0}", _file_name);
        }
        TextAsset asset = bundle.LoadAssetSync(_file_name, typeof(TextAsset)) as TextAsset;
        if (asset == null)
        {
            throw new ExceptionEx("配置文件assetbundle中不包含: {0}", _file_name);
        }
        try
        {
            Byte[] bt = new byte[asset.bytes.Length];
            Array.Copy(asset.bytes, bt, bt.Length);
            bundle.Unload(true);
            return(bt);
        }
        catch (Exception e)
        {
            Log.Error("[SheetLiteDbAssetBundle]Failed to open sheet {0} \nmsg:  {1}.", _file_name, e.Message);
        }
        return(null);
#endif
    }