Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

runInEditMode

Discussion in 'EditorXR' started by jimjahan, Apr 15, 2017.

  1. jimjahan

    jimjahan

    Joined:
    Feb 13, 2015
    Posts:
    13
    I have a simple autoRotate script. Having an EditorVR tool that creates a cube, then adds autoRotate component to it, then sets runInEditMode to true for the added component, creates a non-rotating cube. What is wrong with this approach? Is it possible to create objects with live updates (like auto-rotating objects) in EditorVR?
     
  2. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Well, a few things to check -- if you always want your autorotate component to execute, then you might simply add the [ExecuteInEditMode] attribute to the class. Otherwise, if you set runInEditMode on the component to true, then it should just run, but that would depend on EditorVR being open, since that is what forces update ticks. Feel free to share your code.
     
  3. chantey

    chantey

    Joined:
    Mar 5, 2017
    Posts:
    49
    Out of interest, thats precisely a feature of the comp entry im working on

    Code (CSharp):
    1. [ExecuteInEditMode]
    2.     public class ZodiacMono : MonoBehaviour{
    3.  
    4.         void Update ()
    5.         {
    6.             transform.RotateAround (transform.parent.position, transform.parent.up,0.1f);
    7.         }
    8.  
    oh n by the way my Unity EVR shortcut just swapped places with regular Unity in my start menu, i believe it means im officially using Unity EVR more often :)
     
  4. jimjahan

    jimjahan

    Joined:
    Feb 13, 2015
    Posts:
    13
    Thanks for your reply. I tried both methods but they don't work. I changed MakeCubeTool in temp folder. Please find the attached files.

    If I put some Debug.Log in update, I can see the output in console but the cube will not rotate.
     

    Attached Files:

  5. amirebrahimi_unity

    amirebrahimi_unity

    Joined:
    Aug 12, 2015
    Posts:
    400
    Ahh...The issue is Time.deltaTime. You have to use Time.unscaledDeltaTime for this to work currently. When we update the custom editor build to 5.6 (planned for EVR 0.0.6 release), then this problem won't exist.