当前位置:   article > 正文

unity自动保存功能_unity 2020 设置自动保存

unity 2020 设置自动保存

今天unity崩了两次,导致我的工程重写两次!!!我整个人都要炸了
于是在网上找了autosave的攻略

unity版本:2020α(18,19应该也可以)
在工程文件的assets文件夹创建Editer文件夹,在Editer文件夹下写一个autosave.cs文件,代码如下

using UnityEditor;
using UnityEngine;
using UnityEditor.SceneManagement;

[InitializeOnLoad]
public class AutoSave
{
    // Static constructor that gets called when unity fires up.
    static AutoSave()
    {
        EditorApplication.playModeStateChanged += (PlayModeStateChange state) => {
            // If we're about to run the scene...
            if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
            {
                // Save the scene and the assets.
                Debug.Log("Auto-saving all open scenes... " + state);
                EditorSceneManager.SaveOpenScenes();
                AssetDatabase.SaveAssets();
            }
        };
    }
}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

reference: https://forum.unity.com/threads/we-need-auto-save-feature.483853/
侵删

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/141678
推荐阅读
相关标签
  

闽ICP备14008679号