Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by Oddeye01 · Dec 20, 2013 at 02:22 PM · animationanimatorloop4.3

Loop Time through Script 2D 4.3

I am attempting to create animations through a script, since many of my characters will follow the same 2d Spritesheets. So far I have been able to construct the animation clip, but I am unable to check the "loop time" box through script. This loop time can be seen in the inspector of an animation clip, and is by default checked when used the mechanim.

I have used tried the wrapmode, but this has no effect.

Heres my code so far:

EditorCurveBinding curveBinding = new EditorCurveBinding();

     // I want to change the sprites of the sprite renderer, so I put the typeof(SpriteRenderer) as the binding type.
     
     curveBinding.type = typeof(SpriteRenderer);
     
     // Regular path to the gameobject that will be changed (empty string means root)
     
     curveBinding.path = "";
     
     // This is the property name to change the sprite of a sprite renderer
     
     curveBinding.propertyName = "m_Sprite";
     
     
     
     // An array to hold the object keyframes
     
     ObjectReferenceKeyframe[] keyFrames = new ObjectReferenceKeyframe[6];
     
     
     
     for (int i = 0; i < 6; i++)
         
     {
         
         keyFrames[i] = new ObjectReferenceKeyframe();
         
         // set the time
         
         keyFrames[i].time = timeForKey(i);
         
         // set reference for the sprite you want
         
         keyFrames[i].value = spriteForKey(i);

         Debug.Log(keyFrames[i].time + " frame: " + keyFrames[i].value);
         
         
         
     }
     

     AnimationUtility.SetAnimationType(animClip, ModelImporterAnimationType.Generic);
     AnimationUtility.SetObjectReferenceCurve(animClip, curveBinding, keyFrames);
     animClip.wrapMode = WrapMode.Loop;

     AssetDatabase.CreateAsset(animClip, "Assets/Animations/testing/MyAnim.anim");
     AssetDatabase.SaveAssets(); 



Is there some simple call to access the loop time/ loop pose boolean?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer Wiki

Answer by Oddeye01 · Dec 23, 2013 at 05:34 AM

After working on this error for sometime and talking in the scripting forums, it appears you are not able to currently access the loop time variable. It resides in the animationclipsettings object, but you can not access the set method.

To help anyone who is building multiple animations through scripting, the fastest way to handle the loop time boolean is to select all created animations (using shift and ctrl), go to the inspector, right click the inspector tab, select debug, and check the loop time box. You must go do debug to select loop time for multiple objects.

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

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

18 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

Related Questions

Can't play animation after setting GameObject to inactive and back to active again 5 Answers

Snapping Child to Root after Animation 2 Answers

Animation Loop 2 Answers

How can I reset a non-looping animation? 0 Answers

Animation keeps playing even with "loop" deactivated. 1 Answer


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