经过测试,上面方法是获取当前正在编辑的场景(包括Prefab),下面的方法是获取主场景,就是在Prefab编辑场景下获得的也是外面打开的普通场景。 最终使用 UnityEditor.SceneManagement.StageUtility.GetCurrentStageHandle().FindComponentsOfType 解决了问题。
经过测试,上面方法是获取当前正在编辑的场景(包括Prefab),下面的方法是获取主场景,就是在Prefab编辑场景下获得的也是外面打开的 普通场景。 最终使用 UnityEditor.SceneManagement.StageUtility.GetCurrentStageHandle().FindComponentsOfType 解决了问题。©2022 Baidu |由 百度智能云 提供计算服务 | 使用百度前必读 |...
using System.Collections; using System.Collections.Generic; using UnityEngine; public class SSDirector : System.Object { //singlton instance private static SSDirector _instance; public ISceneController CurrentScenceController { get; set; } //get instance public static SSDirector GetInstance() { if ...
1:Editor下打开新窗口需要继承EditorWindow,然后使用获取窗口即可,注意放在Editor文件夹下 1publicclassDrawGameLevel : EditorWindow2{3[MenuItem("Maps/Creater %M")]//后面快捷键4publicstaticvoidOpenMapCreate()5{6DrawGameLevel window = EditorWindow.GetWindow<DrawGameLevel>("地图编辑器");7window.Show();...
OnSceneGUI MenuItem 与 EditorWindow ScriptableWizard ScriptObject Attributes AssetProcess OnDrawGizmos OnDrawGizmos是在MonoBehaviour下的一个方法,通过这个方法可以可以绘制出一些Gizmos来使得其一些参数方便在Scene窗口查看。 比如我们有一个沿着路点移动的平台,一般的操作可能是生成一堆新的子物体来确定和设置位置,但...
通过脚本遍历Project窗口中的所有scene 文件,并在菜单栏生成下拉列表,点击对应的场景就能快速的切换过去。 首先创建ScenesMenuBuild.cs 并将下面的代码复制进去 usingSystem.Collections;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Text;usingUnityEditor;usingUnityEditor.SceneManagement;usingUnityEngine;///...
会在菜单栏出现Scenes选项,如下图 点击Update This List ,则会在Assets目录下生成Scripts/Editor/ScenesMenu.cs,该脚本的内容就是每个scene对应的MenuItem.此时就可以在Scenes下拉列表里面快速的切换场景进行编辑了。 发布于 2019-07-14 23:08 Unity(游戏引擎) ...
Static Variables loadedSceneCount The number of loaded Scenes.Static Functions CloseScene Close the Scene. If removeScene flag is true, the closed Scene will also be removed from EditorSceneManager. GetSceneManagerSetup Returns the current setup of the SceneManager. MarkAllScenesDirty Mark all the...
在Editor模式(而不是Playing模式)下,写在代码中的类似【Input.GetKeyDown】是无效的,是无法获取键盘/鼠标操作信息的,取而代之的是使用类似【Event.current.type == EventType.MouseDown】检测输入。 它的使用可以在Editor的面板下,也可以在场景视图中(SceneView)。 1. 简单输入 点击面板,按下【A】键,打印信息;...
Unity Editor 基础篇(三):自定义窗口 【Unity编辑器】扩展总结四:创建编辑器窗体 一、EditorWindow示例 整体效果 image.png usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEditor;usingUnityEditor.SceneManagement;usingSystem.IO;publicclassMyFirstWindow:EditorWindow{//用于储存记录Bu...