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

[CodeSource]Table and ListTable editable from Inspector, similar to Dictionary.

Discussion in 'Scripting' started by IsGreen, Jul 15, 2014.

  1. IsGreen

    IsGreen

    Joined:
    Jan 17, 2014
    Posts:
    206
    Download link.


    And for what? It allows us to use the name or even your GameObject Tag to assign an object (texture, Sound, Script, Collider, or any other part Rigidbody etc ...)

    Think that you can create a Texture2D variable in the script, and from there to assign texture.

    But what happens if you have 100 objects in the scene, and later decide to change the texture? You must change one by one the texture in each script.

    However, if you create tables with game resources (textures, sounds, etc ....), allows you to modify the game or scene during its course from a table or list of content without having to access each GameObject by separated.



    Image Views from Inspector:




    The left side of the image shows the Table class that assigns the image displayed on the map each GameObject, according to their tag.

    The right side of the image shows the ListTable class with a group of listing multiple images corresponding to a sprite sheet.

    Both classes can add and remove elements dynamically during program execution, and from edit mode.

    There is a problem from edit mode, not allowed to use generic parameters in classes.

    So, if you need other types different to Texture2D or string, will need to modify them from MonoDevelop.
     
    Last edited: Jul 16, 2014
    jister likes this.