-
-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a new asset type equivalent to Unity's ScriptableObject. #30
Comments
I support this idea |
for me is a long no-go for xenko. |
Just wanted to show support for this feature. I think a scriptable data asset would be a great addition to the engine. At the moment it is sort of possible in a hacky kind of way by using a prefab with an empty entity and single script, but I think a dedicated asset would be excellent. Many games need to store read only data that doesn't need to be in an external file for things like item configurations, level data etc. It makes sense to use the powerful editor and serialization that is already available. Here's how I imagine it could be added: 1: Create a new base class 'DataScript' or similar that users would inherit from along with adding all the asset serializers and processors etc. I'm no expert, but those are my thoughts on the idea and think it would be a useful addition for many users. |
I'm of the opinion the c# environment is powerful enough that scriptableobject isn't really needed. Yes, what you end up doing in Xenko is creating an entity with priority -1, and add a script to it. The script will be a class with a static reference to itself (Singleton), which holds whatever game data you need. That is how I'm currently handling it. I don't think we need a special entity to represent these easy steps. |
Yes, that is fair enough. But what if the data should be accessible in multiple scenes? Then you would either have to load the data scene first and keep it alive, or clone the data which comes with its own issues, namley keeping the data in sync between scenes. This is why I use a prefab to store data but it just seems clumbsy and hacky. I come from a Unity background and when they added a scriptable object asset i didn't really see the point either. However, once you use it and see the flexibility and endless number of uses, it really does become a great feature to have. |
Just for my understanding, the main feature is that you can edit the values in the editor, right? Otherwise, there are many ways to achieve that with common programming patterns, like singleton, services, and so on... |
Yes that is one of the main benefits, but also the fact that they are not coupled to a scene instance or entity in any way. It's a bit like reading in a file and deserializing it as a class instance, except that you get all the editor and serialization features of xenko instead of having to do that manually. |
As far as I understand a similar functionality can be achieved by creating a custom A good next question is: should the data in the asset be mutable? If so, it might be necessary to create a new game system that would manage these objects, otherwise when the reference count goes to 0 and later the asset gets reloaded it would lose the modified state. |
An easy way to add custom asset types might be enough. That's the main thing I am missing about scriptable objects. Raw assets can be used for this at the moment but it lacks the advantage of type safety that a proper solution would yield. |
You can already create custom data assets, quite easily. I've prepared a small demo project: |
Oh nice 👍 |
Note that custom asset types discussed in #1120 Plugin system RFC would solve this with minor overhead. |
Posting in support of scriptable objects being a core feature for Stride. I can live without a lot of things, but data objects aren't one of them |
I have seen multiple different descriptions what people used ScriptableObject for - so maybe this feature needs to be described on its own in order to get a clear scope that can be worked with. To make matters worse 😂, I'll add a description of my use case - which is even more complex to implement than what I have heard so far, but also a huge advantage for teams with specialized roles. I have the following class in Unity: [CreateAssetMenu(menuName = "Epics/DamageType")]
public class DamageType : ScriptableObject
{
public Color color;
} The first line (the But I guess "the magic" is that if a script now has a field It can also reference other assets. For example, I could add a field I actually do have a chain like this:
Script => ScriptableObject => Prefab => Script => ScriptableObject The main point is that in a whole bunch of cases, it's a rather quick way to However, I also realize that there are multiple parts to implementing this. On the engine side, I think it's mostly "just" deserializing a referenced file into But on the Game Studio side, off the top of my head
Uiuiui. Big cost, big reward, eh? |
Important to note this feeature likely isnt far. Manios POC mostly works here https://github.com/manio143/StrideCustomAsset but just requires you restart the editor when code changes are made.
|
Once we make progress on #1120 I'm hoping I will be able to effectively provide single line attribute similar to what is described above which would run a source generator over a Content class and create the asset definition and the asset compiler for it. |
Improve simulation test api
Hi,
Though I have never used Unity I feel that the ScriptableObject is quite valuable. Being able to design a data object and save it with various values so scripts can share instances can really improve design time support in editor.
cheers,
dfkeenan
The text was updated successfully, but these errors were encountered: