Unity3d editor: how to prevent changes from being undone upon exiting play mode?

前端 未结 3 1935
庸人自扰
庸人自扰 2021-01-15 14:04

Apparently this is some beginner\'s question (and that I am) but it\'s driving me crazy and I couldn\'t find any mention:

I Occasionally forget to exit P

相关标签:
3条回答
  • 2021-01-15 14:40

    You can select objects you want to keep while in play mode, copy them with Ctrl + C, and then just paste them back in with Ctrl + V after returning to edit mode. Then you can eithr delete the originals from the scene or copy values from individual components like @Programmer suggested.

    0 讨论(0)
  • 2021-01-15 14:42

    Other Unity coders have had this problem before me and they came up with a neat solution. Setting the UI to a different colour while in playmode "Playmode tint".

    You can read the details here (originally posted 2009 but I have checked it still works in latest Unity 5.3):

    http://answers.unity3d.com/questions/9159/best-strategies-for-not-accidently-editing-whilst.html

    0 讨论(0)
  • 2021-01-15 14:48

    There is no settings to prevent changing things during play mode but there are ways to reduce the chances of losing changes during play mode.

    1.Edit->Preferences... -> Colors. Now, on the right change Playmode Tint to red. That will remind you you are making changes in play mode.

    2.Click on the gear icon of each component you change during play then click Copy Component. When are done with playmode, select the component you want to keep its changes. Click the gear icon again and this time, Click Paste Component Values.

    3.Write an Editor Plugin that will do that for you. This is hard but possible.

    Use event to find out when entering playmode. Store all GameObject public important variables such as transform/rigidbody properties in a list.

    Wait for the stop event to fire then ask your self which GameObjects to overwrite settings to. Then overwrite the properties of the selected GameObjects That's it.

    Usefull APIs for this:

    EditorApplication.isPlaying
    EditorApplication.isPaused
    EditorApplication.isPlayingOrWillChangePlaymode
    EditorApplication.playmodeStateChanged += callBackFunc;
    EditorApplication.HierarchyWindowItemCallback
    EditorApplication.ProjectWindowItemCallback
    

    Note: According to Unity roadmap, a feature that enables you to save playtime changes is in construction and will be released soon but the above seems to be the only way at this time.

    0 讨论(0)
提交回复
热议问题