Skip to content
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

Ability to create your own resource types #7037

Closed
mikasasukasa opened this issue Nov 4, 2016 · 11 comments
Closed

Ability to create your own resource types #7037

mikasasukasa opened this issue Nov 4, 2016 · 11 comments

Comments

@mikasasukasa
Copy link

What do I mean?

Well, since Resources are just data containers, this should not be too complex to achieve. What I mean is to, somehow, be able to create your own Resource type, making it possible to create data files and edit them within the editor.

How would it work?

My sincere apologies if it's not welcome to show how other engines do it, but I think it's interesting to exemplify. I will just not mention the framework/editor I'm talking about, but that's how one can create a Resource:

http://image.prntscr.com/image/fc4489a3b0104102974c6b08da2dd965.png

After compiling it, it's possible to edit the public properties (similar to export vars) of said Resource. Reminder: The Resource itself won't do any thing, it just stores data for the game to handle. The Resource's file extension could be fileName.resourceName.res.

Let's say I create a Resource type called Character and I name it George... Its filename would be george.character.res. There are other ways to name it, though (or maybe leaving it as field, so the user names it however they want).

When would it be useful?

That's a great way to make databases. One could make a --xml, json, ini or whatever-- the game would read and then would just create Resources for the game. Let's say I created a Weapon Resource, and a Character one. The Weapon Resource would contain: A string called Name, and a int called Damage.

The Character Resource would contain: A string called Name, and a ResourceRef called Weapon. Then I could give the weapons a name and a damage. Also give the Character a name and a weapon.

Then, I could create a Sprite node that would be my character, with a ResourceRef and properly load its data. Not only set its weapon but the stats, appearence, or whatever I wanted.

I hope I'm clear and if there's already a feasible way to achieve this within Godot, let me know how.

@vnen
Copy link
Member

vnen commented Nov 4, 2016

You can make custom resource with an EditorPlugin. It's quite similar to making a custom node as described in the documentation, just replacing the base type to "Resource" (or one of it's subtypes).

It's still a bit cumbersome, since you can't use this custom types as export hints and it's a bit difficult to make a custom editor for your Resource type, since it's impossible to save it through the plugin (#6603). Still, it's possible to create, edit, and save them from the Inspector dock like any other Resource type.

@KioriSun
Copy link

KioriSun commented Nov 7, 2016

@vnen to me it seems like he is talking about something like unity's ScriptableObjects, which are a nice thing to have anyways.

@mikasasukasa
Copy link
Author

So... no chance for this to become a thing?

@vnen
Copy link
Member

vnen commented Nov 8, 2016

@indiemaatheus did you even read my previous comment? I literally said it is already possible to create custom Resource types (just might not be in the ideal format yet, but there's always margin for improvement). If this is not what want, then describe it in another way.

BTW, I don't use Unity and have no idea what ScriptableObjects are.

@mikasasukasa
Copy link
Author

Well, I did not mean to annoy you. What I asked is that - once you said it's "a bit cumbersome" process - if it was going to get some more attention from the team. And no, I'm not talking about an Unity's feature since I've never used it, but the idea is pretty simple and is probably the same as what KioriSun described.

@reduz
Copy link
Member

reduz commented Nov 8, 2016

you can already make a .gd that inherits from resource, then instance those
and save them to a file

On Tue, Nov 8, 2016 at 5:46 PM, indiemaatheus [email protected]
wrote:

So... no chance for this to become a thing?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#7037 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF-Z22eLL4F1vzpup92kCkbBgkc8vVCqks5q8N-hgaJpZM4KqEI5
.

@vnen
Copy link
Member

vnen commented Nov 8, 2016

It'll get improved, it's just not a priority for now. There's always community members working on stuff though, so maybe it gets looked sooner.

@willnationsdev
Copy link
Contributor

I created this Inheritance Dock plugin that I think will make this much easier.

@ghost
Copy link

ghost commented Apr 7, 2018

The original issue should be fixed with @vnen's comment here: #7037 (comment) IIUC?

@salvob41
Copy link
Contributor

If you wondering how to make a .gd as a resource. This post in the dev forum answers it:

https://godotengine.org/qa/8139/need-help-with-exporting-a-custom-ressource-type

@Calinou
Copy link
Member

Calinou commented Oct 2, 2019

I'll close this as the base feature is now implemented. There are a few proposals related to improving custom resource usability, such as godotengine/godot-proposals#18.

@Calinou Calinou closed this as completed Oct 2, 2019
@akien-mga akien-mga added this to the 3.1 milestone Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants