Skip to content

Commit

Permalink
v0.11.92 整理 ResKit 的示例 & 增加自定义扩展 Res 的示例
Browse files Browse the repository at this point in the history
  • Loading branch information
liangxiegame committed Apr 6, 2021
1 parent db507f8 commit 4733280
Show file tree
Hide file tree
Showing 103 changed files with 364 additions and 23 deletions.
33 changes: 17 additions & 16 deletions Unity2017/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,6 @@
<Compile Include="Assets\QFramework\Extensions\UIKitTransition\Scripts\UI\UITransitionPanel.cs" />
<Compile Include="Assets\QFramework\Extensions\UIKitTransition\Scripts\UI\UITransitionPanelComponents.cs" />
<Compile Include="Assets\QFramework\Extensions\UIKitTransition\UITransition.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\0.PackageKitExample\IOCExample\InjectExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\0.PackageKitExample\IOCExample\IOCFrameworkExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\0.PackageKitExample\IOCExample\MainContainer.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\0.PackageKitExample\IOCExample\NetworkExampleService.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\0.PackageKitExample\TypeEventSystemExample\TypeEventSystemExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\ActionKitExample\0.DelayNode\DelayNodeExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\ActionKitExample\1.EventNode\EventNodeExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\ActionKitExample\2.SequenceNode\SequenceNodeExample.cs" />
Expand All @@ -204,24 +199,29 @@
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\CSharpExtensionExample\ExtensionExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\CSharpExtensionExample\GameObjectExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\CSharpExtensionExample\TransformExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\IOCExample\InjectExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\IOCExample\IOCFrameworkExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\IOCExample\MainContainer.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\IOCExample\NetworkExampleService.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\Pool\CallPool.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\RefCounter\RefCounterExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\SingletonExample\0.Singleton\Singleton.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\SingletonExample\1.MonoSingleton\MonoSingletonExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\SingletonExample\2.SingletonProperty\SingletonProperty.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\SingletonExample\3.MonoSingletonProperty\MonoSingletonProperty.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\SingletonExample\4.MonoSingletonPath\MonoSingletonPath.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\1.CoreExample\TypeEventSystemExample\TypeEventSystemExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\0.BasicUsage\ResKitExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\1.LoadAssetBundleResExample\AssetBundleResExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\Audio\AudioTest.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\ImageLoaderExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\LoadResourcesResExample\LoadResourcesResExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\LoadSceneExample\LoadSceneExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\NetImageExample\NetImageExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\Pool\CallPool.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\RefCounter\RefCounterExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\ResKitExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\ResLoaderRelateUnloadAsset\ResLoaderRelateUnloadAssetExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\10.CustomResExample\CustomResExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\2.LoadResourcesResExample\LoadResourcesResExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\3.LoadSceneExample\LoadSceneExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\4.ResLoaderRelateUnloadAsset\ResLoaderRelateUnloadAssetExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\5.LoadSpriteAtlasExample\TestSpriteAtlas.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\7.LoadSceneExample\ResKitExampleMain.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\8.NetImageExample\ImageLoaderExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\8.NetImageExample\NetImageExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\ResourcesExample.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\SceneExample\ResKitExampleMain.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\2.ResKitExample\SpriteAtlas\TestSpriteAtlas.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\3.UIKitExample\ManagerOfManagersExample\Enemy.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\3.UIKitExample\ManagerOfManagersExample\EnemyEvent.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\3.UIKitExample\ManagerOfManagersExample\EnemyManager.cs" />
Expand All @@ -246,6 +246,7 @@
<Compile Include="Assets\QFramework\Framework\Examples\3.UIKitExample\UIExample\UIKitExample_LoadFromResources\Scripts\UI\UISomePanelFromResources.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\3.UIKitExample\UIExample\UIKitExample_LoadFromResources\Scripts\UI\UISomePanelFromResources.Designer.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\3.UIKitExample\UIExample\UIKitExample_LoadFromResources\Scripts\UIKitExample_LoadFromResoruces.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\4.AudioKitExample\Audio\AudioTest.cs" />
<Compile Include="Assets\QFramework\Framework\Examples\4.AudioKitExample\AudioExample.cs" />
<Compile Include="Assets\QFramework\Framework\Plugins\ICSharpCode.SharpZipLib\BZip2\BZip2.cs" />
<Compile Include="Assets\QFramework\Framework\Plugins\ICSharpCode.SharpZipLib\BZip2\BZip2Constants.cs" />
Expand Down

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using UnityEngine;

namespace QFramework
{
public class CustomResExample : MonoBehaviour
{
// 自定义的 Res
public class MyRes : Res
{
public MyRes(string name)
{
mAssetName = name;
}

// 同步加载(自己实现)
public override bool LoadSync()
{
// Asset = 加载的结果给 Asset 赋值
State = ResState.Ready;
return true;
}

// 异步加载(自己实现)
public override void LoadAsync()
{
// Asset = 加载的结果给 Asset 赋值
State = ResState.Ready;
}


// 释放资源(自己实现)
protected override void OnReleaseRes()
{
// 卸载操作
// Asset = null
State = ResState.Waiting;
}
}

// 自定义的 Res 创建器(包含识别功能)
public class MyResCreator : IResCreator
{
public bool Match(ResSearchKeys resSearchKeys)
{
return resSearchKeys.AssetName.StartsWith("myres://");
}

public IRes Create(ResSearchKeys resSearchKeys)
{
return new MyRes(resSearchKeys.AssetName);
}
}

// Use this for initialization
void Start()
{
// 添加创建器
ResFactory.AddResCreator<MyResCreator>();

var resLoader = ResLoader.Allocate();

var resSearchKeys = ResSearchKeys.Allocate("myres://hello_world");

var myRes = resLoader.LoadResSync(resSearchKeys);

resSearchKeys.Recycle2Cache();

Debug.Log(myRes.AssetName);
Debug.Log(myRes.State);
}
}
}

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

Loading

0 comments on commit 4733280

Please sign in to comment.