Jump to content
  • Advertisement

SongOfDurin

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About SongOfDurin

  • Rank
    Newbie

Personal Information

  • Role
    Programmer
  • Interests
    Art
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. SongOfDurin

    Item representation in Unity

    Ja ich spreche Deutsch :). I think I mentioned your Option 2 in one of my last posts With this approach I should be able to centralize my Prefab/Item creation. Then I could use my "item name" or "item id" as the key value and access the prefab over the prefab path in my specific item. But it seems really odd to do this. As I started with Unity I programmed a custom editor and used Scriptable Objects for my class hierarchie. The bad thing about this was the fact that I had to save every Item Instance as an asset to my "asset database" and after I switched my base class to an abstract base class I got a big surprise: It roasted my whole database. While researching this stuff I decided to to avoid as much as possible because with other serialization technics I get the same resul, with much less effort.
  2. SongOfDurin

    Item representation in Unity

    Because Unitys serialization system sucks as hell. In my opinion it is not really possible to write object oriented C# Scripts when Unity is not be able to serialize custom classes/generics without hacking something together like there is no morning. Therefor it shouldn´t be more complex then writing my own system especially when there are libraries like Json.NET which has very cool features for JSON serialization. But no matter which system I use, the make me some headache because I don´t know how to connect the "raw data" with the prefabs/gameobjects properly. Maybe my english is to bad to express my exact problem. **Edit https://feedback.unity3d.com/suggestions/serialization-of-polymorphic-dat Some inspiration from other developers
  3. SongOfDurin

    Item representation in Unity

    Hey Kylotan thanks for your reply and sorry for my absence!!! I think something is wrong with my brain or with Unity. It´s true, Unity´s Prefab System exists to hold the recipes for specific entities but I can hardly believe that adding thousands of prefabs to a GameObject is the right way. Many developers from which I have read the dev. log used databases like MongoDB, SQLLite, CouchDB or what ever to store their data...so there must be a way or a pattern to associate the metadata from my items (damage, defense, special effects...) with specific prefabs/objects in Unity. The only way I can think of to achieving this is to create the prefab through a custom editor and save all paths into my item and serialize it or create a component system and add only a "prefab component" to items which need a visual representation (and save all relevant infos in this specific component) Would this be a valid option too?
  4. SongOfDurin

    Item representation in Unity

    Hi Kylotan, thanks for your reply. At the moment I have an abstract class called "BaseItem" which serves as the base of all evil. The classes Consumable, Obstacle and Material inherit from the root class. All items share some base information like ItemID, ItemName, ItemDescription, ItemValue, QuestItem and the child classes have some extra functions, extra fields ect... Now I can use JSONUtility or the YAMLDotNet Library to de/serialize all that stuff and create objects in code. If Iuse the .json format I could go further and use MongoDB to manage all that stuff (for example). But thats only the "definition" of the items and the way I save them on the disk. Now imagine I load my Database in some sort of data structure when the game starts which gives me the possibility to iterate through all my items at runtime or do other fancy stuff. The next step could be an abstract Item Factory. If I want to spawn a mushroom I could say "Hey Consumable Factory, create some nice mushrooms for me". Then the spawn system can get some sort of notification to spawn that shit at position X/Y. Now I try to ask my question in a diffrent way: Should I create the prefabs for each Item manually and save only the paths into my database so that I can do something like this: Instantiate(Ressources.Load<SomeType>(SomeType.prefabPath)) OR Should I create the "game objects" dynamically with some sort of factory like: Okay Consumable Factory, I need a mushroom and a mushroom needs a Rigidbody2D, a BoxCollider and a SpriteRenderer.
  5. Hi all, I´m currently working on a little 2D "explorer game" in Unity and do have some problems with the item database. First I created a simple XML Database in which I stored things like ItemValue, ItemDescription.....and also the Path to the specific prefab. Because I wanted to manage my Database only in one place, I started to build a Custom Editor and used Scriptable Objects to represent my desired Item Hierarchy. At this point I learned a lot about Unity´s crappy serialization system and how you have to do "big" workarounds to save your Database without any restriction like "No support for custom null classes, no support for polymorphism....) . I started to realize that I have to setup my own little "system" to get the job done but I can´t get my head around the whole thing. 1) Lets say I have the raw data representation of my Items (ItemID, ItemDescription, ItemValue e.g) saved in a .json or .yaml file, how do I map the "raw data" to the visual part of the item (in game)? Should I create the Items dynamically (e.g create some factorys for diffrent item types and build them in code)? Should I rewrite my "custom editor" to create acutal prefabs and save the path to my desired item like I did in the XML thing? Is there an best practice for this kind of problem in Unity? Kind regards,
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!