Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

I've just released a plugin that allows you to design animator assets through a C# interface

Discussion in 'Animation' started by CSharpAnimator, Feb 11, 2019.

  1. CSharpAnimator

    CSharpAnimator

    Joined:
    Feb 5, 2019
    Posts:
    7
    Hey guys, I've developed a (non-free) asset that allows you to create animators in a declarative form using C#. This approach allows you to generate an animator using C#, solving common problems such as the need to copy similar transitions many times and the need to hard code things like transition condition values.

    Link

    Personally I've found this solution saves me hours, but please let me know what you think of it.

    Other forum post with more examples
     
    Last edited: Feb 11, 2019
    SilentSin likes this.
  2. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    156
    Sounds useful. I like the look of the construction syntax you're using, though I'm not a fan of the "_BaseClass" suffix on CSharpAnimator.

    I hate using AnimatorControllers at all, but if I had to go back to them I'd definitely consider getting this.
     
  3. CSharpAnimator

    CSharpAnimator

    Joined:
    Feb 5, 2019
    Posts:
    7
    Thanks for the feedback! Yeah I admit "_ClassBase" was a pretty arbitrary decision. How come you don't like it? What do you do to get around the use of animators currently?
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    3,611
    Check his sig! I'm in the same camp, I prefer to build a custom solution on top of Playables rather than using AnimatorControllers at all.


    How are you getting this stuff to compile?

    Code (csharp):
    1.  
    2. Animator
    3.         (
    4.             // This is the root of the graph. Inside of here we can define only layers.
    5.             Graph()
    6.             [
    7.                 // Each layer typically takes a name, and it's often a good idea to define a default state.
    8.                 Layer("Base").DefaultState("Idle")
    9.                 [
    10.                     // States and sub state machines are defined within states. Check the advanced test for how to use state machines inside
    11.                     // of layers. Typically a state will take a name(necessary for transitions to reference it), and a motion.
    12.                     State("Idle", idleMotion),
    13.                     State("Run", runMotion),
    14.                     State("Jump", jumpMotion)
    15.                 ]
    16.             ],
    17.  
    18. ..etc
    19.  
    I haven't seen the syntax before. It's really readable, but you've got to be doing something fancy with your graph and layer types. to allow the [] declaration.
     
    SilentSin likes this.
  5. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    156
    Just because it's unnecessary. If the class is only supposed to be used via inheritance and can't be used on its own, make it abstract.

    The Playables API gives you much more freedom in how you can control animations so I made my own system called Animancer (as Baste said, there's a link in my signature).
     
  6. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    156
    I was stumped too at first, but it's just an overloaded indexer (the [] operator). They're sort of a mix of properties and methods, and I assume he's using indexers that take params arrays.
     
  7. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    3,611
    ... That has to be an overloaded index getter, right? Otherwise the syntax would be [Foo()] = bar;

    That's crazy. I like it.
     
  8. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    156
    Yeah, it's a getter and the result goes into the outer method call. Probably the most creative use of C# syntax I've seen and it lets him use "[]" instead of ".Method()".
     
  9. SilentSin

    SilentSin

    Joined:
    Jan 3, 2013
    Posts:
    156
    @CSharpAnimator

    Also, I'd recommend making your full documentation available online so people can look more into it before needing to decide if they want to risk buying something that might not work how they expect. I used to just upload my PDF manual to Google Drive and put a link on the store page, but I recently found an awesome tool called Wyam which makes it really easy to generate a customisable website that includes automatic API documentation based on your XML comments.
     
    CSharpAnimator likes this.
  10. CSharpAnimator

    CSharpAnimator

    Joined:
    Feb 5, 2019
    Posts:
    7
    Yeah that's all it is. The method(i.e "Transition()", "State()") returns an object that overrides the [] operator, and the [] operator takes a params array and stores it in that object. I think I got the idea for this syntax from UE4's Slate API. I've never used it, but from reading some examples, I thought of this.