Search Unity

Does Unity support Envelopes for variables?

Discussion in 'Scripting' started by madpuppet, Apr 18, 2012.

  1. madpuppet

    madpuppet

    Joined:
    Apr 17, 2012
    Posts:
    15
    I'm a unity newbie. I have a script with a few variables the move from 0..1 over time.
    I'd like the user to be able to control the speed they move over time using an envelope.

    Should I be using Animation components for this? I had a look but they seemed like they are more suited for applying a single animation to the transform of a GameObject.

    Ideally what I want is little envelope windows in the gui where the user can edit an envelope for each variable in the script instance. (ie. add/remove/move nodes with the horizontal axis having a 0..1 time range and the vertical axis being 0..N).

    Can anyone point me in what direction I should be investigating? If not supported already, is this sort of thing possible as a GUI addon?
     
  2. BeerHuntor

    BeerHuntor

    Joined:
    Apr 7, 2012
    Posts:
    82
  3. madpuppet

    madpuppet

    Joined:
    Apr 17, 2012
    Posts:
    15
    Thanks, but No, I don't mean ingame GUI. I mean I want the envelope to be a (C#) public variable that is editable in the Inspector window.
     
  4. BeerHuntor

    BeerHuntor

    Joined:
    Apr 7, 2012
    Posts:
    82
    Should be possible, I think. But i wouldn't know how to. Sorry.
     
  5. madpuppet

    madpuppet

    Joined:
    Apr 17, 2012
    Posts:
    15
    So it seems the unity editor is also written using that GUI system, so worst-case I could write an envelope extension.

    http://unity3d.com/support/documentation/Components/gui-ExtendingEditor.html

    Before I do, I'd love to know if I'd be re-inventing the wheel (plus that will be a fair bit of R&D for me to work out how).
     
  6. madpuppet

    madpuppet

    Joined:
    Apr 17, 2012
    Posts:
    15
    Found it.

    public AnimationCurve my_variable;


    Gives me exactly what I want. Just had to find the right name.
     
  7. BeerHuntor

    BeerHuntor

    Joined:
    Apr 7, 2012
    Posts:
    82
    Glad you figured it out :)