블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2797)
Unity3D (853)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (61)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
Unity Crash

I’m sure it’s happened to every Unity developer with some frequency: You’re there working on something, totally in the flow and getting mad work done, and all of a sudden BAM! Unity crashes. Unfortunately for you, you’ve probably been so “in the zone” that you haven’t saved the last fifteen minutes or more of that work.

Yes, learning to press CTRL-S regularly is the most effective solution possible, but everyone forgets once in a while and the price for forgetting can sometimes be particularly high.

One thing that would help is if Unity could auto-save your scene for you, and there are a number of Unity editor extensions out there to help you, but it seems the majority of them are either more complicated than you need or don’t quite work right. That’s why I wrote the following script, which saves the current scene prior to entering Play mode when you press the Play button. It requires no configuration, and doesn’t distract you from the ultimately most important task of developing your game.  There are no editor windows to keep open, no menu options that need to be clicked.

If this sounds helpful to you, you can either copy the code below into a C# script file somewhere in an Editor folder in your project, or click the button below to download a zipped .unitypackage that can be easily imported into your project.


Download “AutoSave on Run Script”AutoSaveOnRun.zip – Downloaded 58 times – 2 kB

[code lang="csharp" toolbar="true" title="AutoSaveOnRun.cs"]
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;

using UnityEngine;
using UnityEditor;

[InitializeOnLoad]
public class AutoSaveOnRun
{

static AutoSaveOnRun()
{

EditorApplication.playmodeStateChanged = () =>
{

if( EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying )
{

Debug.Log( "Auto-Saving scene before entering Play mode: " + EditorApplication.currentScene );

EditorApplication.SaveScene();
EditorApplication.SaveAssets();
}

};

}

}
[/code]
I really do hope you find this as useful as I have!


출처 : http://www.daikonforge.com/dfgui/save-on-run/

반응형

'Unity3D > Extensions' 카테고리의 다른 글

ObjectPool  (0) 2014.04.22
인스펙터 상의 GUI를 비활성화 시키고 싶을 때..  (0) 2014.04.02
Save Scene while on play mode  (0) 2014.01.12
Combine Children Extented (sources to share)  (0) 2013.01.17
SpriteManager  (0) 2012.11.24
Posted by blueasa
, |