Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question how to make the display of all the fields of an object inside unity.

Discussion in 'Scripting' started by BATXSUN, Jun 9, 2023.

  1. BATXSUN

    BATXSUN

    Joined:
    Apr 4, 2022
    Posts:
    2
    Hi. I ran into a small problem, but it's worth starting with explanations. I have a serializable class Inventory_class, it has some fields, as well as a sheet of type Items_object. Items_object, in turn, is a class created for items. Up to the current moment, everything is working well, It is beautifully displayed inside unity.

    upload_2023-6-9_9-19-58.png

    upload_2023-6-9_9-11-49.png

    maybe something that you have refers to elements that are not related to Items_object
    public class Bees_item : Items_object
    And if we create an object of the Bees_item class and write to a previously created sheet inside the Inventory_class object

    and in this case, if we write a bee in the inventory sheet, then its fields will not be displayed

    upload_2023-6-9_9-18-45.png

    Is there any method to display the extended fields Bees_item?


    I will be very glad of your answer. Thank you all
     

    Attached Files:

  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    If you're talking about serialising inherited types, that needs to be done with SerializeReference, though there isn't built in inspector for it.

    However for inventory items you should really consider using ScriptableObjects instead.
     
    CodeRonnie and Yuchen_Chang like this.
  3. BATXSUN

    BATXSUN

    Joined:
    Apr 4, 2022
    Posts:
    2
    I read about the ScriptableObjects and this is not exactly what I need, are there any other methods?
     
  4. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,043
    Why do you think this? What you're doing is exactly what SOs are made for.
    I don't see any benefit in accumulating these disparate objects into a list like that.

    And even if you really badly want it like that, create SOs independently, then hook them up to a list.