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
8
Question by N1nja · Jun 15, 2010 at 06:33 PM · updateloopframeexecuteineditmodeeach

ExecuteInEditMode is not working.

I have code identical to what you see below. It appears Update does run at least Once, when I first click the scene object, and play with any scene stuff.. but it's definitely not every frame.. In addition neither FixedUpdate or OnGUI are having any effect. I have NOOOO idea what the problem is here, as from everything I read about this, says the code shown below is valid. Placing a () after ExecuteInEditMode changes nothing.

[ExecuteInEditMode] public class MyCustomBehaviour : MonoBehaviour { public void Update() { Debug.Log("."); // Will run in edit mode. }

 public void FixedUpdate()
 {
     Debug.Log("..");
 }

 public void OnGUI()
 {
     Debug.Log("...");
 }

}

Fixed: For anyone having issues related to this problem, remember that it's not every frame that Update is called.. but only when it is needed to be called.. meaning the objects state much change in some way first.. so I went ahead and created a CustomEditor for my script, and applied EditorUtility.SetDirt(target); inside of OnInspectorGUI();, what that did was tell Unity the objects state has changed, and Unity automatically invokes the scripts Update method(function). Because, OnInspectorGUI is updated each XXX frames, it then updates the script each XXX frames. Sorry for mah retarded moment. Thanks!

Comment
Add comment · Show 6
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 PatHightree · Nov 28, 2010 at 11:30 PM 0
Share

Thanks very much for posting your workaround.

avatar image Joshua · Sep 06, 2011 at 05:54 AM 0
Share

"remember that it's not every frame that Update is called.. but only when it is needed to be called."

It is called every frame.. the frames itself just aren't refreshed all that often.

avatar image steinbitglis · Feb 21, 2012 at 06:38 PM 0
Share

According to the reference: "The functions are not called constantly like they are in play mode. - Update is only called when something in the scene changed."

avatar image psantoki · Sep 06, 2013 at 06:28 PM 0
Share

*EditorUtility.SetDirty

avatar image psantoki · Sep 06, 2013 at 07:14 PM 0
Share

Also, in Unity 4.2 OnInspectorGUI does not get called at constant time (claimed the OP, "OnInspectorGUI is updated each XXX frames").

Things that do trip the OnInspectorGUI event

  1. Selecting your target object in Scene View

  2. Dragging the Console window around

  3. Clicking randomly in the Inspector Pane

  4. Clicking on objects in the Project

Things that do not cause the event to fire

  1. Just sitting in the editor

  2. Scrolling in the Project list

  3. Flipping between Game and Scene panels

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Eric5h5 · Jun 15, 2010 at 07:12 PM

It's definitely updating every frame. The editor doesn't try to draw frames as fast as possible...that would be a huge waste of CPU time in the editor. It only updates when it needs to (that is, when something changes). OnGUI and Update do work; don't know about FixedUpdate.

Comment
Add comment · Show 5 · 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 N1nja · Jun 15, 2010 at 07:28 PM 0
Share

How can I get it to update every frame..? It only updates when its neccesary; but the Particle Emitter is able to animate particles each frame, I assume it uses this attribute and runs the code that animates each particle in Update.. so how would I get my system to do that? =|

avatar image fherbst · Jun 15, 2010 at 07:55 PM 0
Share

$$anonymous$$aybe you could let any object oscillate really, really small in your Update()-function? This will probably cause the editor to refresh because something visible has changed.

avatar image fherbst · Jun 15, 2010 at 07:56 PM 0
Share

Additional thought: the particles probably derive from some class (Transform?) which causes a redrawing of the scene on every change.

avatar image Eric5h5 · Jun 15, 2010 at 10:54 PM 0
Share

Particle systems only continuously update as long as they're actively selected. If they're not selected then they don't update.

avatar image yoyo · Sep 06, 2011 at 05:03 AM 0
Share

Any tips on handling user input in an ExecuteOnEdit$$anonymous$$ode component, or is that not advisable? I tried various things, all with curiously delayed results.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to prevent Unity to execute all the code in the first frame. 1 Answer

Is it possible to call a method once per frame inside of another method? 2 Answers

Copy position into var without updating every frame 2 Answers

Force refresh of frame 2 Answers

Update function - Auto update 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