Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

QuickInspector - Simple Sliders for Picky Clients

Discussion in 'Works In Progress - Archive' started by Jacob-Williams, Sep 30, 2014.

  1. Jacob-Williams

    Jacob-Williams

    Joined:
    Jan 30, 2009
    Posts:
    267
    Hey all,
    I spent most of yesterday trying to come up with a way to expose certain variables to a client in a way that will work across multiple projects. My initial idea was to create a text based console, but on touch devices that is less than ideal.

    What I came up with is a generic system that allows you to expose any int or float and have it controlled with run-time sliders. For my purposes, I used Unity's legacy GUI system because it allowed me to write a GUI for the system in about 15 minutes, but any UI solution would work just fine.

    Here is what the code looks like:
    Code (CSharp):
    1.  
    2. void Update() {
    3.    QuickInspector.CreateQuickInspector(ref myFloatOrInt, "Category", "Variable Name", minValue, maxValue);
    4. }
    And here is the "default" GUI that the client will see:


    And finally, here is what you will see in the editor.


    I am not sure if anyone else would find this useful, but if you have worked on a lot of client projects, you know that tweaking to a client's taste can waste quite a bit of time. If you think this is something you would use, let me know and I will clean up the code and write some documentation. If there is a lot of interest, I may extend it a bit and sell it for a few bucks on the Asset Store.
     
  2. VesuvianPrime

    VesuvianPrime

    Joined:
    Feb 26, 2013
    Posts:
    135
    This is looking really nice! While the client angle is compelling, for me this would be useful for testing things at runtime.

    What does it look like when "closed"? Is there a little header that can be re-opened?

    I see you're using ref int/float values. Are you able to make it compatible with properties?
     
  3. Jacob-Williams

    Jacob-Williams

    Joined:
    Jan 30, 2009
    Posts:
    267
    @VesuvianPrime - that's a great point. It's difficult to play with settings if you're not running from the editor, and on mobile devices it's not always a perfect match.

    When the UI is closed, it slides up to where only the button at the bottom remains. Here's a gif:


    As for using properties, there is a method for that already, but it doesn't provide the same syntactic sugar that using refs gives me.

    It looks something like this:
    Code (CSharp):
    1. someClass.MyProperty = QuickInspector.CreateQuickInspector(someClass.MyProperty, "Some Class", "My Property", 0, 10f);
    If there is anything else you think would be helpful, I'm all ears.
     
  4. VesuvianPrime

    VesuvianPrime

    Joined:
    Feb 26, 2013
    Posts:
    135
    Already I really want to use this!

    The only thing I can think of right now is providing other field types. Keeping to the client theme, I think buttons and checkboxes would be important. But really, I could use it immediately in its current form.