Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Aethon · Jan 30, 2018 at 01:35 PM · scripting problembuildscript.animator controllermechanim

UnityEditor.Animations API in a build

I've been working with mecanim scripting; switching in and out different types of animations using the Animator Override Controller. This worked fine on its own however I also needed to edit the transitions before and after using the UnityEditor.Animations API, this is due to some animations needing a longer duration or cutting them short to blend correctly dependent on the overridden animation my usage shown below:

 UnityEditor.Animations.AnimatorStateTransition forwardsAttackTransitionEnter;
 UnityEditor.Animations.AnimatorStateTransition backwardsAttackTransitionEnter;

 animatorOverrideController = new AnimatorOverrideController(animator.runtimeAnimatorController);
 animator.runtimeAnimatorController = animatorOverrideController;
 
 UnityEditor.Animations.AnimatorController animationController = animatorOverrideController.runtimeAnimatorController as UnityEditor.Animations.AnimatorController;
 
 foreach(var anyStateTransition in animationController.layers[0].stateMachine.anyStateTransitions)
 {
     if (anyStateTransition.name == "forwardsAttackTransitionEnter") forwardsAttackTransitionEnter = anyStateTransition;
     if (anyStateTransition.name == "backwardsAttackTransitionEnter") backwardsAttackTransitionEnter = anyStateTransition;
 }
 
 forwardsAttackTransitionEnter.hasExitTime = weaponData.weaponDictionary[currentWeapon].hasExitTimeEnter;
 forwardsAttackTransitionEnter.exitTime = weaponData.weaponDictionary[currentWeapon].exitTimeEnter;
 forwardsAttackTransitionEnter.duration = weaponData.weaponDictionary[currentWeapon].transitionDurationEnter;
 forwardsAttackTransitionEnter.offset = weaponData.weaponDictionary[currentWeapon].transitionOffsetEnter;
 
 animatorOverrideController["SwordSwing"] = weaponData.weaponDictionary[currentWeapon].weaponforwardAnim;

This works "okay" in the editor (the animator skips for a second as the new transition data is entered) but building this unfortunately won't work as the Unity Editor namespace isn't included for standalone builds.

Is there a way to get this code to work in a build or a similar way to get this done using the normal API, if not are there any assets that expose the animator run-time variables like this, or any other ways to implement what I'm trying to achieve?

Thanks for your time - Aaron

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by shrinath-kopare · Jan 30, 2018 at 03:57 PM

This might help you...have a look http://shrinath-kopare.blogspot.in/2018/01/adding-and-controlling-animator.html

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Aethon · Jan 31, 2018 at 10:24 AM

@shrinath-kopare Thanks for the help, unfortunately I'm looking to edit the transition settings at run-time instead of running an animation on any game object.

Thanks for the effort though!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shrinath-kopare · Jan 31, 2018 at 11:06 AM 0
Share

Ohh! You are welcome.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

187 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Animation not working when Camera is attached to script 0 Answers

Adding additional C# scripts after build (Android, iOS) 1 Answer

How can I split a List ? 0 Answers

I want to do a pause panel 1 Answer

OPC UA Client & Server SDK for .NET not working on Unity from www.traeger.de 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges