• 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
2
Question by AlucardJay · Jul 29, 2012 at 12:55 AM · editorexecuteineditmode

ExecuteInEditMode : scene wants to be saved even after no change

W$$anonymous$$le using @script ExecuteInEditMode to view my meshes and textures in edit mode, I am noticing that the scene wants to be saved even if no changes have been made. For example if I open the project, then change between scenes then there is no save prompt. But if I $$anonymous$$t play then stop, the scene prompts to be saved. Why is t$$anonymous$$s, and how could it affect my scene if I choose to save or not to save (that is the question!)

 @script ExecuteInEditMode

(in function)

 // Assign material UVs to mesh UVs
 var theMesh : Mesh;
 if (!EditorApplication.isPlaying) {
     theMesh = theObject.GetComponent(MeshFilter).sharedMesh as Mesh;
 }
 else {
     theMesh = theObject.GetComponent(MeshFilter).mesh as Mesh;
 }

here is a package with 2 scenes included to show the issue, swapping between scenes is fine, $$anonymous$$t play then stop and change scenes and there is a 'Save Scene' prompt : http://www.alucardj.net16.net/unityquestions/Editor_Issue.unitypackage

Edit : My editor problems are not only with t$$anonymous$$s question. If anyone has information that could shed light on t$$anonymous$$s, it would be greatly appreciated. I have similar problems with a mesh creator I wrote with it's own editor script (can instantiate mesh in edit mode, w$$anonymous$$le playing the verts are animated, but after stopping and restarting the verts don't animate, whether I just re-assign the verts or reconstruct the mesh inc recalculateBounds/Normals, other cases where textures don't update after play-stop-play). Creating these editor classes would be great and really handy for stage layouts instead of constantly $$anonymous$$tting play and making minor adjustments.

t$$anonymous$$s comes from my answer that can be found here : http://answers.unity3d.com/questions/290643/atlas-tool-like-ngui.html

Comment
Add comment · Show 2
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 reptilebeats · Jul 29, 2012 at 01:09 AM 0
Share

thats strange i don't get this and i have an empty project just containing draw call minimiser and your parser, my Execute in edit mode is just under pragma strict, but apart from that it should be exactly the same. very strange

avatar image AlucardJay · Jul 30, 2012 at 01:20 PM 0
Share

I've changed the title in a last attempt to hopefully find someone who knows why this situation is occuring, and how I can deal with this (or if I should just ignore it if there is no effect to the project).

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Bunny83 · Jul 30, 2012 at 02:30 PM

You said you don't change anyt$$anonymous$$ng, but your script has t$$anonymous$$s line w$$anonymous$$ch is executed in Start:

 theMesh.uv = theUVs;

w$$anonymous$$ch changes the uv array when you enter editmode since you use the "evil" ExecuteInEditMode.

A change doesn't mean a certain value is different from the old one. T$$anonymous$$s would also cause an object to be marked as dirty:

 transform.position = transform.position;

If you don't want t$$anonymous$$s, don't execute it in editmode.

If you want be able to "update" the uv settings in the editor, just add a context menuitem to execute t$$anonymous$$s when you want it to update and not every time you enter editmode.

edit
Another t$$anonymous$$ng: You shouldn't use EditorApplication in a runtime script. You can't build your project now, try it...

If you want to include editor specific stuff in a runtime script, make sure you use conditional compilation

 #if UNITY_EDITOR
 //Do editor stuff here
 #endif


Comment
Add comment · Show 2 · 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 AlucardJay · Jul 30, 2012 at 05:03 PM 0
Share

Thankyou very much, this is exactly the information I needed to help realize what is happening. Looking at my 'Flexi-Sprite' class, I can now see how this is being affected in the same way.

This is the first time I have used EditorApplication (no, hadn't published a build so didn't notice!) but am always using if ( Application.isEditor || Application.isWebPlayer ) to swap between mouse and touch inputs (for testing), from now on I shall use #if UNITY_IPHONE

I'll also practice with @script AddComponentMenu in mesh scripts and @MenuItem in my custom editor scripts to avoid using ExecuteInEditMode, but without exposing variables for the UVs there, I cannot as yet see how to set the texture to display correctly in edit mode.

Again, thankyou for looking, I hope the scripts wern't too long and tedious to read through, but I did imagine my problem would be obvious to someone who was familiar with these kinds of methods. I really do appreciate this. Well I should stop chattering on as I have alot of editing and testing to do =]

off-topic : many thanks for your json reader, I implemented and tested it, and was able to search and return values. Is it ok if I use it in my projects (private and commercial), or (attempt to) write a JS version (as all my scripts are currently JS, and don't want compilation issues when building to iOS)?

avatar image Bunny83 · Jul 30, 2012 at 05:12 PM 0
Share

Feel free to use it ;) I posted it already on the unify wiki. It can also be used to create a json string out of an object hierarchy if needed.

The parser isn't polished yet, but should work in most cases ;)

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Editor, detect Save or Rebuild Event 1 Answer

Execute in EditMode every time a script's parameter is changed 0 Answers

Manually triggering a script from the editor (utility, macro etc.) 1 Answer

using ExecuteInEditMode to create platforms in the editor 1 Answer

How to prevent editor to set the scene dirty if a script changes a mesh (@ExecuteInEditMode) 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