Пример #1
0
        public override byte[] ReadFile(string fileName)
        {
            if (!fileName.EndsWith(".lua"))
            {
                fileName += ".lua";
            }
#if !RES_AB
            string path = FindFile(fileName);
            byte[] str  = null;

            if (!string.IsNullOrEmpty(path) && File.Exists(path))
            {
#if !UNITY_WEBPLAYER
                str = File.ReadAllBytes(path);
#else
                throw new LuaException("can't run in web platform, please switch to other platform");
#endif
            }

            return(str);
#else
            fileName += ".bytes";
            var getter = ResHelper.LoadAsset(fileName);
            var res    = getter.Get <TextAsset>(ResHelper.GetPubAssetGetterGo());
            return(res.bytes);
#endif
        }
Пример #2
0
        public void PlaySound(string soundPath)
        {
            //AudioClip clip = Resources.Load(soundPath) as AudioClip;
            var       getter = ResHelper.LoadAsset(soundPath);
            AudioClip clip   = getter.Get(gameObject) as AudioClip;

            normalSource.PlayOneShot(clip);
        }
Пример #3
0
        public void PlayBGMusic(string musicPath)
        {
            //AudioClip clip = Resources.Load(musicPath) as AudioClip;
            var       getter = ResHelper.LoadAsset(musicPath);
            AudioClip clip   = getter.Get(gameObject) as AudioClip;

            BGMusicSource.clip = clip;
            BGMusicSource.Play();
        }
Пример #4
0
        void LoadSlicingData(string terrainName)
        {
            if (slicingData != null)
            {
                return;
            }
            string slicingDataPath = string.Format("terrainslicing/{0}/{1}_slicingdata", terrainName, terrainName);
            var    getter          = ResHelper.LoadAsset(slicingDataPath);

            slicingData = getter.Get(terrainRoot) as TerrainSlicingData;
            trunkSize   = new Vector2(slicingData.terrainSize.x / slicingData.slicingSize, slicingData.terrainSize.z / slicingData.slicingSize);
            mapTilesize = new Vector2(slicingData.terrainSize.x, slicingData.terrainSize.z);
            Logger.LogWarp.LogFormat("{0}, {1}", mapTilesize, trunkSize);
        }
 static int LoadAsset(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         UFrame.ResourceManagement.AssetGetter o = ResHelper.LoadAsset(arg0);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Пример #6
0
    void TestDatbase()
    {
        GameObjectGetter gogetter        = ResHelper.LoadGameObject("prefabs/cube");
        GameObject       cubeGo          = gogetter.Get();
        AssetGetter      assetgetterBlue = ResHelper.LoadAsset("materials/blue");
        Material         mBlue           = assetgetterBlue.Get(cubeGo) as Material;

        cubeGo.GetComponent <Renderer>().material = mBlue;


        AssetGetter assetgetter = ResHelper.LoadAsset("materials/mymaterial");
        Material    m           = assetgetter.Get <Material>(gameObject);



        var getter = ResHelper.LoadGameObject("prefabs/ui/ui_login");

        getter.Get();
    }