-
2020-12-23 21:13:36更多相关内容
-
Unity编辑器选中场景物体并且聚焦
2021-05-07 20:33:19Unity编辑器选中场景物体并且聚焦 void SelectedPoint(string gameObjectName) { //给物体赋值 GameObject gameObject = _character.FindObj(gameObjectName); //类似你在层级窗口中点击了物体,他会自动展开...Unity编辑器选中场景物体并且聚焦
void SelectedPoint(string gameObjectName) { //给物体赋值 GameObject gameObject = _character.FindObj(gameObjectName); //类似你在层级窗口中点击了物体,他会自动展开层级 EditorGUIUtility.PingObject(gameObject); //聚焦物体 Selection.activeGameObject = gameObject; SceneView.lastActiveSceneView.FrameSelected(); } ///主要就是这些了下面是Findobj的补充 怕上面的FindObj你们不知道是什么,这是我写的UnityGame Object拓展 ///主要查找物体的所有层级是否有叫_name的物体,返回第一个 public static GameObject FindObj(this GameObject gameObject,string _name) { //获得所有层级包括隐藏的 Transform[] transforms = gameObject.GetComponentsInChildren<Transform>(true); //长度 int transLength = transforms.Length; //迭代和返回 for (int i=0;i< transLength; i++) { if(transforms[i].name.Equals(_name)) { return transforms[i].gameObject; } } return null; }
-
Unity Selection编辑器类
2021-01-30 12:21:45SelectionSelection是编辑器类,需要放在在Assets/Editor目录下。SelectionModeSelectionMode//编辑器方法[MenuItem("Assets/SelectionMode/SelectionMode.TopLevel")]public static void SelectUnfiltered(){...Selection
Selection是编辑器类,需要放在在Assets/Editor目录下。
SelectionMode
SelectionMode
//编辑器方法
[MenuItem("Assets/SelectionMode/SelectionMode.TopLevel")]
public static void SelectUnfiltered()
{
UnityEngine.Object[] arr = Selection.GetFiltered(typeof(UnityEngine.Object), SelectionMode.TopLevel);
for (int index = 0; index < arr.Length; index++)
{
string filePath = AssetDatabase.GetAssetPath(arr[index]);
Debug.Log("FilePath" + filePath);
}
}
SelectionMode.Unfiltered
选中一个:返回选中的一个路径;
选中多个:返回选中的多个路径。
SelectionMode.TopLevel
当选中一个:跟SelectionMode.Unfiltered结果一致;
当一次选中多个:返回第一个选中的一个路径。
SelectionMode.Deep
返回所有包括文件夹和预制件的集合
SelectionMode.ExcludePrefab
返回忽略预制件项
SelectionMode.Editable
将从导入的fbx文件中过滤生成的预制件,而不是用户创建的预制件
SelectionMode.Assets
SelectionMode.DeepAssets
收集所有包括文件夹,Assets,子文件夹。
Selection.GetFiltered
static function GetFiltered (type : Type, mode : SelectionMode) : Object[]
if type is a subclass of Component or GameObject the full SelectionMode is supported.
if type does not subclass from Component or GameObject (eg. Mesh or ScriptableObject) only SelectionMode.ExcludePrefab and SelectionMode.Editable are supported.
如果Type是Component或者GameObject的子类,全部selectionMode都可以支持;
否则SelectionMode.ExcludePrefab and SelectionMode.Editable 类型才支持;
默认是:SelectionMode.TopLevel | SelectionMode.ExcludePrefab | SelectionMode.Editable.
-
游戏开发unity编辑器扩展知识系列:获取选中对象
2020-12-23 18:20:21 -
Unity按钮编辑器EditorButton-master
2020-09-24 10:28:10这是一个类编辑器拓展的插件,用户可以通过代码自定义组件面板上的按钮控件,内附示例工程和package包,还有演示gif,感兴趣欢迎下载 -
Unity 编辑器下对Prefab预设的一些操作
2022-02-11 14:54:41//给预设增加AssetBundle名称 [MenuItem("ILFrameWork/Prefab rename", false, 10)] static void reboot_rename() { setPrefabname("xxx"); } //给一个对象命名预设名称,可以选择多个,并单独命名 ... -
Unity编辑器拓展(Hierarchy)
2021-11-07 20:59:10Hierarchy 1.EditorApplication.hierarchyWindowItemOnGUI //绘制的回调 2.... } } 免费课程链接: 独立游戏《Unity打造关卡编辑器》Unity 独立游戏 关卡编辑器https://bycwedu.vipwan.cn/promotion_channels/72762192 -
unity编辑器扩展-project窗口中获取选中的文件夹路径
2021-02-24 11:28:47效果图 拿去直接用吧。代码如下 public static string GetCurrentAssetDirectory() { foreach (var obj in Selection.GetFiltered<Object>(SelectionMode.Assets)) ... var path = AssetDatabase.... -
Unity 编辑器(UnityEditor)
2020-12-19 05:28:53自己看源码经验不是很多,有些感觉无从下手,因为里面的代码跳转太多了,打算先看看NGUI的编辑器是怎么做出来的,于是开始研究Unity的编辑器制作。一、引言Unity允许开发者自己制定编辑器,这也给了我们很多的方便,... -
unity编辑器中打印选中物体所有子物体的坐标并复制到剪贴板
2018-01-31 16:41:30//获取编辑器中当前选中的物体 GameObject obj = Selection.activeGameObject; //如果没有选择任何物体,弹出提示并退出 if(obj == null){ EditorUtility.DisplayDialog("ERROR", "No select obj!!", "ENTRY... -
Unity Editor 按路径选中文件文件夹
2019-02-16 11:59:50public void Select(string path) { Object obj = AssetDatabase.LoadMainAssetAtPath(path); if (obj == null) return; EditorGUIUtility.PingObject(obj); ... -
Unity 编辑器开发(Button)
2021-12-30 15:07:37记录使用GUILayout.Button在编辑器绘制Button按钮 创建脚本UIEditor.cs using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; [CustomEditor(typeof(TestUI))] ... -
Unity编辑器,点击跳到文件位置
2021-07-23 17:06:25string _path = fileInfo.FullName; int index = _path.IndexOf("Assets"); _path = _path.Remove(0, index); Object obj = AssetDatabase.LoadAssetAtPath<Object>(_path); Editor.. -
Unity3D编辑器扩展(三)之对选中对象的操作(Selection类)
2021-01-11 23:50:21Unity3D对编辑器的扩展提高了开发的效率,一般我们使用的是对Inspector面板和Scene视图的扩展,其实对于它们的扩展有一定的局限性。那今天就和大家讨论一下对选中对象的操作处理(Selection类)即用鼠标选中对象,就... -
游戏开发unity编辑器扩展知识系列:自定义编辑器窗口点击右键显示自定义菜单栏
2020-12-23 16:14:16参考: https://docs.unity3d.com/ScriptReference/GenericMenu.html ...using UnityEditor; public class MenuItemForCustomizedWindow : EditorWindow { [MenuI... -
Unity编辑器扩展——在Editor下动态添加监听事件
2021-12-04 13:48:36Unity编辑器扩展,在Editor下动态添加监听事件。 -
基于Unity编辑器开发技能编辑器(三)
2022-05-09 19:42:47} #endif } 上面代码我们可以看到首先有一个枚举类型,用来区分不同的轨道,然后轨道基类里面我们可以看到有2个核心的Rect,我之前说过了技能编辑器里面Rect很重要,需要依靠它计算事件和渲染。那么这两个Rect首先... -
Unity编辑器扩展
2021-08-20 14:47:061.如果是在编辑器顶部添加菜单,直接上代码 public class Tools { //编辑器顶部菜单栏添加自定义选项 //格式 菜单名(可以是已有的,也可自主命名新的)/二级菜单/三级菜单 .... //给菜单选项添加快捷键 %=ctrl... -
Unity 编辑器扩展常用功能
2021-12-28 11:33:51一些编辑器扩展功能收集: using System.Collections.Generic; using System.Linq; using UnityEditor; using UnityEngine; public class TestEditor : EditorWindow { private static TestEditor _window; ... -
unity编辑器一些设置
2022-04-20 16:05:302.Unity 设置程序在后台运行 File > Build Settings... > Player > Resolution and Presentation > Run In Background* √ 设置选中。 *这个设置只在webgl和stand 起作用,ios不起作用。 ... -
Unity 编辑器开发实战【Editor Window】- Filter 物体筛选工具
2021-08-12 14:35:05Unity开发工作中,在Hierarchy窗口搜索栏可以通过物体名称或组件名称对场景中的物体进行搜索,但是并不能满足我们一些其它的搜索要求,例如搜索指定Tag标签的物体,或者指定Layer层级的物体,或者指定Active状态的... -
Unity编辑器扩展——EditorWindow
2021-11-15 20:52:24创建窗口 using System.Collections;...using UnityEditor; public class CreateTrees : EditorWindow { [MenuItem("Window/My Window1")] static void Init() { CreateTrees window = (Cr -
Unity3d编辑器常用标签和方法
2020-09-24 09:13:54刷新编辑器,使刚改变的资源立刻被导入。 AssetDatabase.Refresh() 7.保存所有修改 AssetDatabase.SaveAssets() 8.第二个参数表示是否删除目标文件夹中的子文件夹及子文件 Directory.Delete(exportPath, true); 9.... -
Unity编辑器模式下忽略鼠标选中其他物体
2021-01-12 20:59:14在实际开发过程中,会有特殊需求,比如当选中某个物件之后,进入编辑模式,这时希望鼠标在Scene视图不要再选中其他物体 可以通过Editor.OnSceneGUI中调用HandleUtility.AddDefaultControl来实现 using ... -
unity editor下选中GameObject粘贴复制pos信息
2020-12-19 05:28:57参考:https://blog.uwa4d.com/archives/USparkle_Continuous-optimization.html实现:运行时 选中GameObject后copy坐标信息可粘贴出来实现代码:using System.Collections;using System.Collections.Generic;using ... -
Unity编辑器(一)-- 自定义UI拖拽
2022-03-06 15:44:24没有专门处理UI界面岗位的情况下, 开发者需要自己拼合界面,但是Unity默认的UI创建方式有些不太舒服,需要先Create再选中UI最后才能选中自己想要的UI生成出来,而且创建列表内容较多,没办法直接一眼找到,所以做了... -
Unity编辑器扩展——编辑器样式预览窗口
2021-08-16 18:01:14在进行编辑器扩展时,创建控件的方法一般都会提供一个GUIStyle参数,可以让我们自定义样式,修改背景图,字体大小,颜色等等 Unity内置了很多默认的样式,编写一个样式预览器可以预览所有的样式 ... -
unity编辑器扩展——替换选择物体名字中的内容
2021-11-24 23:08:39名字的特点: 1,有规律 2,有相同的内容 可以用这个工具,修改物体的名字,在菜单中生成的自定义目录...using UnityEditor; public class ReplanName : ScriptableWizard { [MenuItem("DCCTools/Rename")] . -
Unity 编辑器开发实战【Custom Editor】- FSM Editor
2022-01-14 10:07:17本文介绍如何为FSM有限状态机模块实现一个自定义编辑器面板,FSM的详细代码在上一篇文章中有介绍,链接地址:在Unity中构建FSM有限状态机下面是最终效果: 首先,自定义一个编辑器面板,需要用到Attribute:... -
实现Unity Scene选中物体后透视描边效果(初级版本)
2021-03-12 18:03:29@[TOC](实现Unity Scene选中物体后透视描边效果(初级版本)) 这是Unity Scene视图选中物体后的描边效果 废话就不说了直接上代码 // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*...