EditorApplication.currentScene 当前场景

static var currentScene : string

Description描述

The path of the scene that the user has currently open (Read Only)

用户当前打开场景的路径(只读)

All paths are relative to the project folder. Like: "Assets/MyScenes/MyScene.unity"

所有的路径都是相对于工程文件夹, 例如” Assets/MyScenes/MyScene.unity”

// saves the current scene into a new temporary scene.
//存当前场景到一个新的临时场景

import UnityEditor;

@MenuItem ("Example/Save temp Scene %s")
static function SaveTempScene() {
	var path : String [] = EditorApplication.currentScene.Split(char.Parse("/"));
	path[path.Length -1] = "Temp_" + path[path.Length-1];
	EditorApplication.SaveScene(String.Join("/",path));
}
最后修改:2011年6月25日 Saturday 18:32

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。