Comments (3)
Hi,IServiceBundle cannot solve your needs, it is just a service container similar to IoC/DI.
You can use Addressable Asset System or Loxodon.Framework.Bundle to load assets asynchronously.
Can you speak Chinese? If you have QQ, please add my QQ group 622321589
from loxodon-framework.
Hi,IServiceBundle cannot solve your needs, it is just a service container similar to IoC/DI.
I think I am now aware of that. But, it seems to me that I can make a service bundle class that does not implement the interface and can still properly set up and tear down services. My sense is that I would not lose any extra functionalities if I don't implement the interface, but I wanted to confirm.
Here's what I ended up with:
using UnityEngine;
using Loxodon.Framework.Services;
using Loxodon.Framework.Asynchronous;
#nullable enable
// Does not implement IServiceBundle
public class GameDriverServiceBundle
{
private readonly IServiceContainer serviceContainer;
public GameDriverServiceBundle(IServiceContainer serviceContainer)
{
this.serviceContainer = serviceContainer;
}
public async Task Start()
{
GameObject? original = await LoadAsync<GameObject>("GameDriverSupportingComponents");
GameObject newInstance = Object.Instantiate(original!);
// Set up example:
serviceContainer.Register("GameCamera", newInstance.GetComponentInChildren<Camera>());
}
public void Stop()
{
// Tear down
serviceContainer.Unregister("GameCamera");
}
private static async Task<T?> LoadAsync<T>(string path) where T : Object
{
return await Resources.LoadAsync<T>(path) as T;
}
}
from loxodon-framework.
Yes, you are right.
But please do not store GameObject in ServiceContainer, it is an IoC container, storing business logic services or basic components in the container, such as network components, role backpack services, etc.
Maybe you can store your game object in PlayerContext or ApplicationContext.
from loxodon-framework.
Related Issues (20)
- Related to enter play mode settings HOT 6
- Git tag v2.4.5 is not aligned with the version update commit HOT 1
- [Fody]当项目中有其他包引用了Mono.Cecil相关的库文件会报错 HOT 7
- Service container doesn't register generics properly HOT 3
- ProxyType.cs的IsParameterMatch存在问题 HOT 2
- Encryption HOT 3
- Inquiry HOT 3
- [Feature] Split the framework further HOT 1
- Loxodon.Framework.Prefs.DefaultEncryptor带参数的构造函数中key和iv没有赋值啊??? HOT 1
- 请教一下使用ResourcesViewLocator加载的资产什么时候释放呢 HOT 1
- 在FormattableTextMeshProUGUI & TemplateTextMeshProUGUI中Text.text会被自身的OnEnable设置为初始值 HOT 4
- InteractionTargetProxy的Target被意外释放 HOT 4
- 【功能需求】DataBinding:加入数据更新事件监听 HOT 1
- When will v3.0 be released? HOT 1
- 建议为每个包添加 csc.rsp HOT 6
- Loxodon.Framework.Views.TextMeshPro.GenericParameters在绑定引用类型时有概率崩溃 HOT 2
- AsyncViewInteractionAction parameter IViewGroup should be IUIViewGroup HOT 1
- 可以考虑用 CommunityToolkit.Mvvm HOT 7
- framework/AsyncInteractionRequest.lua:1: unexpected symbol near '<\239>' HOT 1
- Fody.MethodDecorator HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loxodon-framework.