Skip to content

Commit

Permalink
新增测试代码和修改BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
sheenli committed Oct 22, 2019
1 parent 3ca914c commit 223c468
Show file tree
Hide file tree
Showing 60 changed files with 1,791 additions and 323 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
.consulo/
.idea/

/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
Expand Down
2 changes: 0 additions & 2 deletions .idea/.idea.UnityResourceManagement/.idea/.gitignore

This file was deleted.

68 changes: 0 additions & 68 deletions .idea/.idea.UnityResourceManagement/.idea/contentModel.xml

This file was deleted.

4 changes: 0 additions & 4 deletions .idea/.idea.UnityResourceManagement/.idea/encodings.xml

This file was deleted.

23 changes: 0 additions & 23 deletions .idea/.idea.UnityResourceManagement/.idea/indexLayout.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.UnityResourceManagement/.idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/.idea.UnityResourceManagement/.idea/modules.xml

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/.idea.UnityResourceManagement/.idea/vcs.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/.idea.UnityResourceManagement/riderModule.iml

This file was deleted.

123 changes: 118 additions & 5 deletions Assets/Example/Example.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,135 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YKFramwork.ResMgr;

public class Example : MonoBehaviour
{
private DefResLoadCfg cfg;
// Start is called before the first frame update
void Start()
{
// var rep = ResMgr.Instance.LoadGroup("test", a =>
// {
// GameObject.Instantiate(ResMgr.Instance.GetRes("Cube_prefab"));
// },null);
cfg = ResMgr.Instance.cfg as DefResLoadCfg;
cfg.Init(() =>
{
Debug.LogError("初始化配置成功");
});
}

// Update is called once per frame
void Update()
{

}

private GameObject mCubePrefab;
private GameObject mp3;
private GameObject mCubeRed;
private void OnGUI()
{
var stH = GUILayout.Height(50);
var stW = GUILayout.Width(200);
GUILayout.BeginHorizontal();
if (GUILayout.Button("load test group",stH,stW))
{
TestLoadGroup();
}

if (GUILayout.Button("del",stH,stW))
{
if (mCubePrefab)
{
GameObject.Destroy(mCubePrefab);
mCubePrefab = null;
}
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
if (GUILayout.Button("get test Group Mp3 ",stH,stW))
{
TestGetRes();
}

if (GUILayout.Button("del",stH,stW))
{
if (mp3)
{
GameObject.Destroy(mp3);
mp3 = null;
}
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
if (GUILayout.Button("get async by url",stH,stW))
{
TestResAsyncByUrl();
}
if (GUILayout.Button("del",stH,stW))
{
if (mCubeRed)
{
GameObject.Destroy(mCubeRed);
mCubeRed = null;
}
}
GUILayout.EndHorizontal();

GUILayout.BeginHorizontal();
if (GUILayout.Button("UnLoad",stH,stW))
{
TestUnLoad();
}
GUILayout.EndHorizontal();

}


public void TestLoadGroup()
{
var rep = ResMgr.Instance.LoadGroup("test", a =>
{
if(mCubePrefab == null)
mCubePrefab = GameObject.Instantiate(ResMgr.Instance.GetRes("Cube_prefab")) as GameObject;
},null);
}

public void TestGetRes()
{
if(mp3 != null) return;
var rep = ResMgr.Instance.GetRes("AchievementUnlocked_mp3");
if (rep == null)
{
Debug.LogError("请先加载资源再同步获取资源");
return;
}
mp3 = new GameObject("mp3");
var audioSource = mp3.AddComponent<AudioSource>();
audioSource.clip = rep as AudioClip;
audioSource.loop = true;
audioSource.Play();
}

public void TestResAsyncByUrl()
{
if(mCubeRed != null) return;
ResMgr.Instance.GetResAsyncByUrl("e://New Folder 2/New Folder/Cube_Red.prefab", cubeRed =>
{
if (cubeRed == null)
{
Debug.LogError("e://New Folder 2/New Folder/Cube_Red.prefab");
}
else
{
mCubeRed = GameObject.Instantiate(cubeRed) as GameObject;
}
});
}

public void TestUnLoad()
{
ResMgr.Instance.UnloadUnused();
}
}
26 changes: 26 additions & 0 deletions Assets/Example/ExampleVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Net;
using UnityEngine;
using UnityEngine.Networking;
using YKFramwork.ResMgr;

public class ExampleVersion:MonoBehaviour
{
private void Start()
{
var getUrl = UnityWebRequest.Get(ResMgr.Instance.cfg.RootABPath + "/version");
getUrl.SendWebRequest().completed += op =>
{
UnityWebRequestAsyncOperation wepop = op as UnityWebRequestAsyncOperation;
if (string.IsNullOrEmpty(wepop.webRequest.error))
{
var ver = new YKFramwork.ResMgr.VersionCtrl.Version(wepop.webRequest.downloadHandler.data);
Debug.Log(ver.version);
foreach (var abInfo in ver.AllAB)
{
Debug.Log("name:"+abInfo.name+"/sha1:"+abInfo.sha1+"/size:"+abInfo.size);
}
}
};
}
}
3 changes: 3 additions & 0 deletions Assets/Example/ExampleVersion.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 223c468

Please sign in to comment.