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 /
avatar image
6
Question by AldestP · Jun 07, 2014 at 05:43 AM · animationrotationcustom editor

Transform using custom editor doesn't recorded in animation

I'm trying to make my own editor so I can rotate object around some point directly on scene view using my own handler.. It's working fine on the scene view but somehow when I try to record it in animation, the rotation change isn't recorded.. when I checked, the value on inspector changes as I rotate using my handler.. I try to rotate it using it's default handler, it's recorded.. but then I used my handler again, the rotation value on animation window doesn't change.. here's my screenshot

alt text

I tried several method and then I noticed that OnValidate function is invoked when I change some attribute through inspector but isn't invoked when I used my handler.. So I think It's probably because the changes on my object isn't validated yet.. anyone know how to validate object manually or anyone has any other idea what's actually happening?

bug.png (41.9 kB)
Comment
Add comment · Show 3
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 Bezzy · Jun 08, 2014 at 02:24 PM 0
Share

Same problem here!

Ironically, this was really annoying in a different tool I did, but now this is exactly the behavior I want, because I'm trying to map hue rotation to a transform.rotation so that I can use quaternion interpolation when there's an Animator Blend.

I've tried SetDirty on everything I touch, to no avail. Hope there's a workaround because this was going to save me lots of work!

avatar image AldestP · Jun 09, 2014 at 09:45 AM 0
Share

I tried this script:

http://docs.unity3d.com/$$anonymous$$anual/editor-CustomEditors.html

And it isn't recorded either..

avatar image dimitroff · Nov 27, 2014 at 06:10 PM 0
Share

I have exactly the same problem, did anybody find a solution?

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Bunny83 · Jun 07, 2014 at 07:38 AM

Well, does your editor use SerializedObject and if not do you use EditorUtility.SetDirty on your object after you changed it?

edit

Since the question got bumped again i had another look at the AnimationWindow code. It looks like the AnimationWindow uses the Undo system to record the changes. There is the "Undo.postprocessModifications" delegate to which the AnimationWindow subscribes to receive all changes that go through the Undo system. So make sure you register all your changes to the Undo system.

If you want to recreate the Transform inspector you might want to take a look how the original is implemented. For example if the rotation GUI got changed, the default TransformInspector executes this line:

 Undo.RecordObjects(this.targets, "Inspector");

Which will record the state of the current selected objects. I'm not sure how or where it records the position / scale change since it uses "EditorGUILayout.PropertyField" which is complicated as hell :D. It's also possible that Unity might perform this Undo registration through the SerializedObject when you call ApplyModifiedProperties(); at the end. ApplyModifiedProperties is implemented in native code, so we don't know what happens there.

Though chances are high that you're missing the ApplyModifiedProperties call at the end of your custom editor code which will actually "submit" the changes you made to the SerializedObject to the actual object.

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 AldestP · Jun 08, 2014 at 05:16 PM 0
Share

I used EditorUtility.SetDirty(target).. I don't know how to use SerializedObject.. any sample code about transfor$$anonymous$$g after being SerializedObject?

avatar image
0

Answer by Alex_May · Feb 29, 2016 at 09:30 PM

I have submitted this as a bug: https://fogbugz.unity3d.com/default.asp?775426_8rnlh0mit52jnbmt

Comment
Add comment · Show 3 · 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 Bunny83 · Mar 01, 2016 at 12:22 AM 1
Share

I doubt that this is a bug. It's more likely you're missing something. Did you attach your code to the bugreport? We (the community) can't see if there is a project attached or not but your bugreport would be pointless without.

Properties edited during OnSceneGUI

This is way to vague. There are many ways how to "edit" things the wrong way.

See my edited answer for more details.

Also your post doesn't seem to be an answer, so a comment would be more appropriate.

You might want to have a look at the examples over here. They always use at least either a SerializedObject and Apply$$anonymous$$odifiedProperties at the end, or they register the change manually with Undo.RecordObject / Undo.RecordObjects.

avatar image Alex_May Bunny83 · Mar 01, 2016 at 03:57 PM 1
Share

Sorry about the answer - I thought this was on the forum for some reason!

I did attach the project to the bug, since this was my first bug report I didn't realise that I should provide instructions to reproduce the bug from scratch.

By "editing properties", I mean that I use a handle to change a vector in OnSceneGUI, this is done simply by e.g. target.offset = Handles.PositionHandle(target.offset). I didn't realise I'd have to add undo / applymodifiedproperties! I didn't even know the latter existed, though I did try SetDirty to no avail. I will have a look at this and get back, since my project is at home and I won't be able to access it until tomorrow.

Thanks for all the info!

avatar image Alex_May Bunny83 · Mar 01, 2016 at 04:46 PM 2
Share

O$$anonymous$$, I reimplemented my solution locally and fixed the OnSceneGUI function to correctly record Undo if the handles moved the object. The animation now records the offset when it's moved using the handle now! Thanks a lot. If anyone finds this in the future here's the code I used in my OnSceneGUI:

     public void OnSceneGUI()
     {
         $$anonymous$$achine m = ($$anonymous$$achine)target;
         EditorGUI.BeginChangeCheck();
         Vector3 p1 = m.transform.InverseTransformPoint(Handles.PositionHandle(m.transform.TransformPoint(m.expelPositionLocal), Quaternion.identity));
         Vector3 p2 = m.transform.InverseTransformPoint(Handles.PositionHandle(m.transform.TransformPoint(m.attachedObjectPosition), Quaternion.identity));
         if (EditorGUI.EndChangeCheck()) 
         {
             Debug.Log("$$anonymous$$oved attach point");
             Undo.RecordObject(target, "$$anonymous$$ove attach point");
             m.attachedObjectPosition = p2;
             m.expelPositionLocal = p1;
             EditorUtility.SetDirty(target);
         }
     }

The trick was to stash the changes in a local vector, then if the change check returned true, record into undo, apply the changes, then set the object to be dirty. The target is still a simple $$anonymous$$onoBehaviour with some public Vector3 members that are edited by the handles in this function.

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

25 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

Related Questions

AirPlane Sway Effect 1 Answer

Character animations accumulate rotation (update: curve missing) 1 Answer

Why one of object's animation has global rotation data, and another has local rotation data? 0 Answers

Animating the rotation 0 Answers

Rotating An Object On Its Axis Once 3 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