Unity5.3之后EditorUtility.SetDirty使用问题

几天前,UE说有时候他们在编辑器内改了prefab但是没有保存,我查了一下,发现项目中Editor中用到了这个接口用来将Scene SetDirty,之前很多地方都是这样用,也没觉得有什么问题,后来仔细查了一下,发现在Unity5.3之后,这个接口使用的场景变了,具体可以在Unity的官方文档中看到:地址

具体如下:

EditorUtility.SetDirty

Marks target object as dirty. (Only suitable for non-scene objects).(将目标Object标记为Dirty(仅适用于non-scene objects))

NOTE: ''Prior to Unity 5.3, this was the primary method of marking objects as dirty. From 5.3 onwards,
with the introduction of Multi-Scene Editing, this function should no-longer be used for modifying objects in scenes. Instead, you should use Undo.RecordObject prior to making changes to the object.
This will mark the object's scene as dirty and provide an undo entry in the editor.''
在Unity 5.3之前,这是将对象标记为脏的主要方法。 
从5.3开始,随着多场景编辑的引入,此功能不应再用于修改场景中的对象。
相反,在对对象进行更改之前,应该使用Undo.RecordObject。 
这会将对象的场景标记为脏,并在编辑器中提供撤消条目

If you are modifying files within a scene and specifically do not want to add an undo entry for your modification, you should use EditorSceneManager.MarkSceneDirty
如果你在场景中修改文件,并且不希望为修改添加撤消条目,则应该使用EditorSceneManager.MarkSceneDirty


If you are using a custom editor to modify serialized properties on a component or an asset, you should be using [pSerializedObject.FindProperty]], SerializedObject.Update, EditorGUILayout.PropertyField, and SerializedObject.ApplyModifiedProperties. This will mark the modified object as 'dirty' and create Undo states for you.

如果你使用自定义编辑器修改component或asset的序列化属性,应该使用[pSerializedObject.FindProperty]],SerializedObject.Update,EditorGUILayout.PropertyField和SerializedObject.ApplyModifiedProperties。 这会将修改的对象标记为“脏”并为你创建撤消状态。

Therefore the only remaining situation in which you should use this function is if you are modifying non-scene objects via some other means, and specifically do not want create an undo entry for your modification. This is rare, and unless you're very sure about requiring this, you probably shouldn't be using this command!
因此,你应该使用此功能的唯一剩余情况是,你是否通过其他方式修改非场景对象,并且不希望为修改创建撤消条目。 这很少见,除非你确定要求这样做,否则你可能不应该使用这个命令!

也就说这个接口在Unity5.3之后被改了,项目中一些代码是老代码,没有改成新的接口,出现了这个问题

Pingbacks are open.

Trackbacks

Trackback URL

Comments

54 Comments

  • pokerqq
    25 May 2019, 03:57 | Reply
    I know this if off topic but I'm looking into starting my own weblog and was wondering what all is required to get set up? I'm assuming having a blog like yours would cost a pretty penny? I'm not very internet smart so I'm not 100% sure. Any recommendations or advice would be greatly appreciated. Appreciate it
  • pokerqq
    25 May 2019, 03:57 | Reply
    I know this if off topic but I'm looking into starting my own weblog and was wondering what all is required to get set up? I'm assuming having a blog like yours would cost a pretty penny? I'm not very internet smart so I'm not 100% sure. Any recommendations or advice would be greatly appreciated. Appreciate it
  • agen slot mesin online
    25 May 2019, 17:58 | Reply
    What a stuff of un-ambiguity and preserveness of valuable familiarity regarding unpredicted emotions. Also visit my weblog
  • agen slot mesin online
    25 May 2019, 17:58 | Reply
    What a stuff of un-ambiguity and preserveness of valuable familiarity regarding unpredicted emotions. Here is my webpage :: [agen slot mesin online](http://antalya-bau.com "agen slot mesin online")
  • rlfi=hd:
    28 May 2019, 18:46 | Reply
    Heya are using Wordpress for your site platform? I'm new to the blog world but I'm trying to get started and set up my own. Do you need any html coding expertise to make your own blog? Any help would be greatly appreciated!
  • rlfi=hd:
    28 May 2019, 18:46 | Reply
    Heya are using Wordpress for your site platform? I'm new to the blog world but I'm trying to get started and set up my own. Do you need any html coding expertise to make your own blog? Any help would be greatly appreciated!
  • backlink
    28 May 2019, 19:55 | Reply
    Hey there exceptional blog! Does running a blog like this require a large amount of work? I've very little knowledge of programming but I had been hoping to start my own blog in the near future. Anyhow, if you have any ideas or techniques for new blog owners please share. I know this is off topic however I just needed to ask. Kudos!
  • backlink
    28 May 2019, 19:56 | Reply
    Hey there exceptional blog! Does running a blog like this require a large amount of work? I've very little knowledge of programming but I had been hoping to start my own blog in the near future. Anyhow, if you have any ideas or techniques for new blog owners please share. I know this is off topic however I just needed to ask. Kudos!
  • http://letmeplay.org
    30 May 2019, 04:49 | Reply
    Hello there, I discovered your blog by way of Google whilst looking for a related subject, your website came up, it seems to be good. I've bookmarked it in my google bookmarks.[X-N-E-W-L-I-N-S-P-I-N-X]Hi there, just become alert to your blog through Google, and found that it's truly informative. I'm gonna be careful for brussels. I'll appreciate when you continue this in future. Lots of other people might be benefited out of your writing. Cheers! my webpage :: bandarq terpercaya ([http://letmeplay.org](http://letmeplay.org/__media__/js/netsoltrademark.php?d=bwlink.io%2Fportalpendaftaran470782 "http://letmeplay.org"))
  • http://letmeplay.org
    30 May 2019, 04:49 | Reply
    Hello there, I discovered your blog by way of Google whilst looking for a related subject, your website came up, it seems to be good. I've bookmarked it in my google bookmarks.[X-N-E-W-L-I-N-S-P-I-N-X]Hi there, just become alert to your blog through Google, and found that it's truly informative. I'm gonna be careful for brussels. I'll appreciate when you continue this in future. Lots of other people might be benefited out of your writing. Cheers! My website: bandarq terpercaya ([http://letmeplay.org](http://letmeplay.org/__media__/js/netsoltrademark.php?d=bwlink.io%2Fportalpendaftaran470782 "http://letmeplay.org"))
  • judi poker online
    30 May 2019, 11:51 | Reply
    Hello! Do you use Twitter? I'd like to follow you if that would be ok. I'm absolutely enjoying your blog and look forward to new posts. my site [judi poker online](http://papaqq99.website "judi poker online")
  • judi poker online
    30 May 2019, 11:51 | Reply
    Hello! Do you use Twitter? I'd like to follow you if that would be ok. I'm absolutely enjoying your blog and look forward to new posts. Here is my website ... [judi poker online](http://papaqq99.website "judi poker online")
  • agen bola online
    01 Jun 2019, 03:32 | Reply
    This is a topic that's near to my heart... Thank you! Exactly where are your contact details though?
  • agen bola online
    01 Jun 2019, 03:32 | Reply
    This is a topic that's near to my heart... Thank you! Exactly where are your contact details though?
  • bitpokerku.info
    01 Jun 2019, 09:40 | Reply
    Woah! I'm really loving the template/theme of this website. It's simple, yet effective. A lot of times it's tough to get that "perfect balance" between user friendliness and appearance. I must say that you've done a superb job with this. Additionally, the blog loads extremely quick for me on Internet explorer. Excellent Blog!
  • bitpokerku.info
    01 Jun 2019, 09:40 | Reply
    Woah! I'm really loving the template/theme of this website. It's simple, yet effective. A lot of times it's tough to get that "perfect balance" between user friendliness and appearance. I must say that you've done a superb job with this. Additionally, the blog loads extremely quick for me on Internet explorer. Excellent Blog!
  • agen poker terpercaya
    03 Jun 2019, 10:33 | Reply
    This is a very good tip particularly to those new to the blogosphere. Simple but very precise info… Appreciate your sharing this one. A must read article!
  • agen poker terpercaya
    03 Jun 2019, 10:33 | Reply
    This is a very good tip particularly to those new to the blogosphere. Simple but very precise info… Appreciate your sharing this one. A must read article!
  • agen casino online
    03 Jun 2019, 16:29 | Reply
    Hmm is anyone else encountering problems with the pictures on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog. Any suggestions would be greatly appreciated. My web page: [agen casino online](http://giacatdaxaydung.com "agen casino online")
  • agen casino online
    03 Jun 2019, 16:29 | Reply
    Hmm is anyone else encountering problems with the pictures on this blog loading? I'm trying to find out if its a problem on my end or if it's the blog. Any suggestions would be greatly appreciated. Look into my blog: [agen casino online](http://giacatdaxaydung.com "agen casino online")
  • agen bola online
    04 Jun 2019, 15:48 | Reply
    Hello there! Do you know if they make any plugins to protect against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any tips?
  • agen bola online
    04 Jun 2019, 15:48 | Reply
    Hello there! Do you know if they make any plugins to protect against hackers? I'm kinda paranoid about losing everything I've worked hard on. Any tips?
  • agen bola online
    04 Jun 2019, 17:00 | Reply
    I'm gone to tell my little brother, that he should also visit this website on regular basis to take updated from newest news. My website ... [agen bola online](http://papaqq99.com/ "agen bola online")
  • agen bola online
    04 Jun 2019, 17:00 | Reply
    I'm gone to tell my little brother, that he should also visit this website on regular basis to take updated from newest news. Also visit my weblog :: [agen bola online](http://papaqq99.com/ "agen bola online")
  • agen casino online
    06 Jun 2019, 14:49 | Reply
    Stunning story there. What occurred after? Thanks! Also visit my web-site :: [agen casino online](http://papaqq99.website "agen casino online")
  • agen casino online
    06 Jun 2019, 14:49 | Reply
    Stunning story there. What occurred after? Thanks! Feel free to surf to my website :: [agen casino online](http://papaqq99.website "agen casino online")
  • papaqq99
    06 Jun 2019, 15:32 | Reply
    Hi, I think your website might be having browser compatibility issues. When I look at your website in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, awesome blog! My site [papaqq99](http://papaqq99.com/ "papaqq99")
  • papaqq99
    06 Jun 2019, 15:32 | Reply
    Hi, I think your website might be having browser compatibility issues. When I look at your website in Firefox, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, awesome blog! Feel free to visit my website: [papaqq99](http://papaqq99.com/ "papaqq99")
  • forum cerita sex
    07 Jun 2019, 11:51 | Reply
    Thanks designed for sharing such a nice thinking, paragraph is fastidious, thats why i have read it fully My web-site [forum cerita sex](http://papaqq99.com/ "forum cerita sex")
  • forum cerita sex
    07 Jun 2019, 11:51 | Reply
    Thanks designed for sharing such a nice thinking, paragraph is fastidious, thats why i have read it fully My blog post ... [forum cerita sex](http://papaqq99.com/ "forum cerita sex")
  • tinyurl.com
    10 Jun 2019, 03:28 | Reply
    What's up, this weekend is nice designed for me, as this occasion i am reading this wonderful informative article here at my residence.
  • tinyurl.com
    10 Jun 2019, 03:28 | Reply
    What's up, this weekend is nice designed for me, as this occasion i am reading this wonderful informative article here at my residence.
  • Agen BandarQ
    15 Jun 2019, 00:00 | Reply
    Hi there to all, the contents present at this web page are actually awesome for people experience, well, keep up the nice work fellows.
  • Agen BandarQ
    15 Jun 2019, 00:00 | Reply
    Hi there to all, the contents present at this web page are actually awesome for people experience, well, keep up the nice work fellows.
  • agen poker online
    15 Jun 2019, 23:47 | Reply
    It's going to be ending of mine day, but before finish I am reading this enormous article to increase my experience.
  • agen poker online
    15 Jun 2019, 23:47 | Reply
    It's going to be ending of mine day, but before finish I am reading this enormous article to increase my experience.
  • bola online
    22 Jun 2019, 01:00 | Reply
    Hello, i think that i saw you visited my web site so i came to “return the favor”.I'm trying to find things to enhance my site!I suppose its ok to use some of your ideas!! Also visit my web page
  • bola online
    22 Jun 2019, 01:00 | Reply
    Hello, i think that i saw you visited my web site so i came to “return the favor”.I'm trying to find things to enhance my site!I suppose its ok to use some of your ideas!! my page ... [bola online](http://sofiaodit.com "bola online")
  • judi casino online
    22 Jun 2019, 04:16 | Reply
    Very good article. I certainly love this site. Continue the good work! My web page
  • judi casino online
    22 Jun 2019, 04:17 | Reply
    Very good article. I certainly love this site. Continue the good work! Also visit my blog post :: [judi casino online](http://papaqq99.com/ "judi casino online")
  • agen judi casino online
    22 Jun 2019, 20:51 | Reply
    Howdy! Would you mind if I share your blog with my zynga group? There's a lot of folks that I think would really enjoy your content. Please let me know. Many thanks My page [agen judi casino online](http://giacatdaxaydung.com "agen judi casino online")
  • agen judi casino online
    22 Jun 2019, 20:51 | Reply
    Howdy! Would you mind if I share your blog with my zynga group? There's a lot of folks that I think would really enjoy your content. Please let me know. Many thanks Here is my blog post ... [agen judi casino online](http://giacatdaxaydung.com "agen judi casino online")
  • forum cerita sex
    26 Jun 2019, 03:44 | Reply
    It's really a nice and helpful piece of info. I am glad that you just shared this useful info with us. Please keep us up to date like this. Thank you for sharing. Feel free to visit my page
  • forum cerita sex
    26 Jun 2019, 03:44 | Reply
    It's really a nice and helpful piece of info. I am glad that you just shared this useful info with us. Please keep us up to date like this. Thank you for sharing. my blog post - [forum cerita sex](http://papaqq99.com/ "forum cerita sex")
  • cerita dewasa
    29 Jun 2019, 22:04 | Reply
    Great post. I used to be checking constantly this blog and I am impressed! Very helpful info specially the ultimate phase :) I deal with such information a lot. I was seeking this certain information for a long time. Thanks and good luck. Here is my website
  • cerita dewasa
    29 Jun 2019, 22:04 | Reply
    Great post. I used to be checking constantly this blog and I am impressed! Very helpful info specially the ultimate phase :) I deal with such information a lot. I was seeking this certain information for a long time. Thanks and good luck. my weblog: [cerita dewasa](http://giacatdaxaydung.com "cerita dewasa")
  • judi casino online
    29 Jun 2019, 23:45 | Reply
    Spot on with this write-up, I actually believe that this web site needs much more attention. I'll probably be back again to see more, thanks for the advice! Take a look at my page :: [judi casino online](http://thenhad.org "judi casino online")
  • judi casino online
    29 Jun 2019, 23:45 | Reply
    Spot on with this write-up, I actually believe that this web site needs much more attention. I'll probably be back again to see more, thanks for the advice! my weblog :: [judi casino online](http://thenhad.org "judi casino online")
  • judi poker online
    29 Jun 2019, 23:52 | Reply
    Thanks for sharing your info. I really appreciate your efforts and I am waiting for your next write ups thanks once again. My homepage [judi poker online](http://papaqq99.website "judi poker online")
  • judi poker online
    29 Jun 2019, 23:52 | Reply
    Thanks for sharing your info. I really appreciate your efforts and I am waiting for your next write ups thanks once again. Here is my website: [judi poker online](http://papaqq99.website "judi poker online")
  • agen judi casino
    01 Jul 2019, 08:27 | Reply
    Superb post but I was wondering if you could write a litte more on this subject? I'd be very grateful if you could elaborate a little bit further. Thank you!
  • agen judi casino
    01 Jul 2019, 08:27 | Reply
    Superb post but I was wondering if you could write a litte more on this subject? I'd be very grateful if you could elaborate a little bit further. Thank you!
  • info judi online info poker online
    15 Jul 2019, 03:49 | Reply
    Hello my family member! I wish to say that this article is awesome, nice written and include almost all significant infos. I'd like to see extra posts like this .
  • info judi online info poker online
    15 Jul 2019, 03:49 | Reply
    Hello my family member! I wish to say that this article is awesome, nice written and include almost all significant infos. I'd like to see extra posts like this .
Post your comment

cancel reply