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
1
Question by roberto_sc · Oct 03, 2013 at 06:02 AM · c#transformdebugging

Find out what's changing the Transform.

It can be tricky to work on a project where there's already a lot of stuff made. I spend a lot of time trying to find code that makes certain objects behave some way.

I usually use System.Environment.StackTrace to know which method is calling what, but is there a way to programmatically find out what is changing some GameObject's Transform?

By what is changing I mean which method is somehow changing the Transform fields or which GameObject may be colliding with it.

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 AndyMartin458 · Oct 03, 2013 at 06:10 AM 1
Share

there is a way with breakpoints, in visual studio, to set a data breakpoint. If you were to set this breakpoint on the specific transform in question, then it will pause and see the stack trace any time that transform is modified. You'll have to do a little research to see how to set that in $$anonymous$$onoDevelop. Here's a place to start http://monodevelop.com/Developers/Tasks/Tools/Debugger

avatar image roberto_sc · Oct 03, 2013 at 08:27 PM 0
Share

@Andy$$anonymous$$artin458 That would be awesome, Andy, I use visual studio. But according to this http://msdn.microsoft.com/en-us/library/350dyxd0%28v=vs.100%29.aspx it doesn't apply to C#... am I wrong??

avatar image AndyMartin458 · Oct 03, 2013 at 08:41 PM 0
Share

Dang, it looks like you are correct that it can only be used in C++. I'm going to post another idea.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Catlard · Oct 03, 2013 at 07:21 AM

I'm probably a bad person for not using break points. But one way to do this is by deactivating game objects. While you're in the middle of playing the game, disable/deactivate the object that you want to investigate. Then you'll get an error that will lead you to at least one of the scripts affecting that object.

If, for example, you have a cat, and the catmover class is moving it (but you don't know what/where the catmover class is), you can disable the cat. Then, when the catmover tries to access the cat's transform, bammo. Nullref leading you directly to the catmover class.

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 uergenoglu · Jan 05, 2016 at 07:47 PM 0
Share

Not sure if this was true back then but I modify the positions of inactive objects and it works fine.

avatar image
1

Answer by ChrisHandzlik · Feb 02, 2020 at 06:02 PM

I've been in the same boat and put together a tool that weaves IL into your assembly that essentially redirects all calls from transform.postion = (or rotation/scale) to Interceptor.Set(transform, newValue) - this is then directly controlled by you and you can get all info necessary. Like which component exactly is doing that change, with fill stack trace and other parameters.

That's all done automatically without modifying your source code.

alt text

https://github.com/handzlikchris/Unity.TransformSetterInterceptor

PS: I know this thread is bit old but it still comes up when searching, thought it'd be good to share here.


transforsetterinterceptorworkflow.gif (504.0 kB)
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

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Global Transform-one place to rule them all. 1 Answer

how to find a point(vector2) between two points(Vector2) of a line (line renderer) 2 Answers

Saving coordinates and transferring them to the second object 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