Search Unity

Feedback Please add an alternative to string refs.

Discussion in 'Game Foundation' started by Amaron77, Jun 22, 2020.

  1. Amaron77

    Amaron77

    Joined:
    Jun 16, 2018
    Posts:
    17
    I really really like the idea of this. Even if all you did was create a standard and strap it onto a bare bones system I think it would be extremely beneficial to the Unity ecosystem.

    I really hope though that the eventual standard will have something in addition to strings for storing in editors and runtime instantiation. I'd prefer to see something like an ItemDefReference which works in editors.
    Example:
    Code (CSharp):
    1. class Weapon: MonoBehaviour
    2. {
    3.     //Designer can set this in the editor.
    4.     public ItemDefReference swordRef;
    5.  
    6.     //Runtime sword.
    7.     public InventoryItem sword;
    8.  
    9.     public void Awake()
    10.     {
    11.         sword = Inventory.main.GetItem(swordRef);
    12.     }
    13. }
    That's not to say that unique StringID's don't have their uses. I think it's great to have them but I would also like something like the above.
     
  2. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    63
    HI @Amaron77 - thanks for the feedback.

    Good news we'll be providing a code-generator very soon in the next release, so that you can create non-string constants from the editor catalog. With that, you can reference these item definition as strongly typed C# reference instead of strings.

    Hope that helps. If you have any other suggestions, feel free to let us know!
     
  3. Yay! I'm keeping one eye on this project, even if I'm not here, just sayin'! :)

    Just one request, or dream or whatever, if you could somehow make the dependency on the Analytics library disappear, that would be super cool. I know it is almost impossible, it is just something to think about if any of you guys have some free Friday afternoon. :)
     
    Last edited by a moderator: Jun 25, 2020
    mingz-unity likes this.
  4. Amaron77

    Amaron77

    Joined:
    Jun 16, 2018
    Posts:
    17
    Well that sounds great but I guess my example wasn't really clear. What I think is needed is direct references that can be set in the editor without code.

    Code (csharp):
    1.  
    2. public ItemDefReference swordRef;
    3.  
    If I put this (or whatever you want to call it) in a monobehaviour it should create an object field or drop down where a designer (not coder) can select an GameFoundation definition object and the editor will serialize that as a direct reference and not a string. When I say direct reference I mean it should work like other unity references and be tracked by Unity so that the reference remains stable even if the string is changed later. Also like other unity objects the reference should be usable for creating the GameObject at runtime.

    Of course any user can easily extend the system with this functionality but the point of Game Foundation is to be a standard right? If you build the "standard" on string refs and then everyone has to start using string refs in their third party standardized code and then we've got a huge problem.
     
  5. mingz-unity

    mingz-unity

    Unity Technologies

    Joined:
    Oct 12, 2017
    Posts:
    63
    Thanks for the suggestion @Amaron77.

    This makes sense. We'll look into this, and I may reach out directly if we need to understand your workflow needs a bit more.
     
    erika_d and GilbertoBitt like this.