当前位置: 首页 > wzjs >正文

网站怎么做需要花钱吗app推广方案怎么写

网站怎么做需要花钱吗,app推广方案怎么写,抖音代运营合作,如何从零开始做网站注意:考虑到编辑器扩展的内容比较多,我将编辑器扩展的内容分开,并全部整合放在【unity游戏开发——编辑器扩展】专栏里,感兴趣的小伙伴可以前往逐一查看学习。 文章目录 前言一、确认弹窗1、确认弹窗1.1 主要API1.2 示例 2、三按钮…

注意:考虑到编辑器扩展的内容比较多,我将编辑器扩展的内容分开,并全部整合放在【unity游戏开发——编辑器扩展】专栏里,感兴趣的小伙伴可以前往逐一查看学习。

文章目录

  • 前言
  • 一、确认弹窗
    • 1、确认弹窗
      • 1.1 主要API
      • 1.2 示例
    • 2、三按钮弹窗
      • 2.1 主要API
      • 2.2 示例
  • 二、进度条
    • 1、主要API
    • 2、示例
  • 三、文件夹操作
    • 1、选择现有文件夹
      • 1.1 介绍
      • 1.2 示例
    • 2、选择或者创建某个文件夹
      • 2.1 介绍
      • 2.2 示例
  • 四、文件操作
    • 1、打开现有文件
      • 1.1 介绍
      • 1.2 示例
    • 2、保存或者覆盖文件
      • 2.1 介绍
      • 2.2 示例
    • 3、保存或者覆盖 Unity 资源文件
      • 3.1 介绍
      • 3.2 示例
  • 五、其他
    • 1、将 Texture2D 纹理压缩为指定的纹理格式
    • 2、查找指定对象所依赖的所有资源
      • 2.1 介绍
      • 2.2 示例
  • 专栏推荐
  • 完结

前言

EditorUtility 是 Unity 编辑器中的一个工具类,专门用于编辑器脚本开发,提供了一系列辅助功能(如文件操作、进度条、弹窗等),帮助简化自定义编辑器功能的实现。

官方文档:EditorUtility

一、确认弹窗

1、确认弹窗

1.1 主要API

EditorUtility.DisplayDialog(“标题”, “显示信息”, “确定键名”);

注意:窗口显示会阻塞逻辑 即一定要对提示窗口做处理后才会显示其他逻辑

1.2 示例

using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if(GUILayout.Button("确认消息窗口")){if(EditorUtility.DisplayDialog("确认弹窗", "确定要进行该操作吗?", "确认")){Debug.Log("点击确认");}else{Debug.Log("点击取消");}Debug.Log("执行完毕");}}
}

效果
在这里插入图片描述

2、三按钮弹窗

2.1 主要API

int EditorUtility.DisplayDialogComplex(“标题”, “显示信息”, “按钮1名字”, “取消按钮名字”, “按钮2名字”);

返回值
- 0-按钮1按下
- 1-取消按钮按下
- 2-按钮2按下

2.2 示例

using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if (GUILayout.Button("三按钮确认弹窗")){int result = EditorUtility.DisplayDialogComplex("三按钮确认弹窗", "确定要进行该操作吗?", "选项1", "取消", "选项2");switch (result){case 0:Debug.Log("选项1被按下了");break;case 1:Debug.Log("取消被按下了");break;case 2:Debug.Log("选项2被按下了");break;default:break;}Debug.Log("三按钮确认弹窗显示完毕");}}
}

效果
在这里插入图片描述

二、进度条

1、主要API

  • 显示进度条

    EditorUtility.DisplayProgressBar(“进度条”, “显示信息”, 进制值0~1);
    
  • 关闭进度条

    EditorUtility.ClearProgressBar();
    

注意:进度条窗口不会卡逻辑,但是需要配合关闭进度条使用

2、示例

using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{float value;[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if(GUILayout.Button("显示更新进度条")){//每次点击加进度条进度value += 0.1f;EditorUtility.DisplayProgressBar("进度条标题", "进度条窗口显示内容", value);Debug.Log("进度条窗口显示完毕");}if(GUILayout.Button("关闭进度条")){value = 0;EditorUtility.ClearProgressBar();}}
}

效果
在这里插入图片描述

三、文件夹操作

1、选择现有文件夹

1.1 介绍

选择现有文件夹(仅能选择已经存在的目录)

string path = EditorUtility.OpenFolderPanel(“窗口标题”, “初始打开的文件夹路径”, “默认选中的文件夹名称”);

返回带上文件夹的完整路径,点击取消返回空字符串

1.2 示例

using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if (GUILayout.Button("显示打开文件夹面板")){string str4 = EditorUtility.OpenFolderPanel("得到一个文件路径", Application.dataPath, "");if (str4 != ""){Debug.Log(str4);}}}
}

效果
在这里插入图片描述

在这里插入图片描述

2、选择或者创建某个文件夹

2.1 介绍

选择或新建文件夹(允许输入新文件夹名称并创建)

string path = EditorUtility.SaveFolderPanel(“窗口标题”, “初始打开的文件夹路径”, “默认选中的文件夹名称”);

返回带上文件夹的完整路径,点击取消返回空字符串

2.2 示例

using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if (GUILayout.Button("打开某个文件夹")){string str3 = EditorUtility.SaveFolderPanel("窗口标题", Application.dataPath, "Editor");Debug.Log(str3);}}
}

效果
在这里插入图片描述
在这里插入图片描述

四、文件操作

1、打开现有文件

1.1 介绍

选择现有文件(仅能选择已经存在的文件)

string path = EditorUtility.OpenFilePanel(“窗口标题”, “文件路径”, “后缀格式”);

1.2 示例

using System.IO;
using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if (GUILayout.Button("选择某个文件")){string str4 = EditorUtility.OpenFilePanel("窗口标题", Application.dataPath, "txt");// 会得到带上文件名的存储路径,可以利用路径读取资源Debug.Log(str4);if (str4 != ""){string txt = File.ReadAllText(str4);Debug.Log(txt);}}}
}

效果
在这里插入图片描述
在这里插入图片描述

2、保存或者覆盖文件

2.1 介绍

保存或覆盖文件(允许输入新文件名称并创建)

string path = EditorUtility.SaveFilePanel(“窗口标题”, “打开的目录”, “保存的文件的名称”, “文件后缀格式”)

2.2 示例

using System.IO;
using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){if (GUILayout.Button("打开文件存储面板")){string str = EditorUtility.SaveFilePanel("保存我的文件", Application.dataPath, "测试文件", "txt");// 会得到带上文件名的存储路径,可以利用路径写入Debug.Log(str);if (str != "") File.WriteAllText(str, "内容");}}
}

效果
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3、保存或者覆盖 Unity 资源文件

3.1 介绍

保存或覆盖文件(允许输入新文件名称并创建)。但是仅限Asset项目内,这是与 SaveFilePanel 的主要区别。返回相对路径,从Asset开始拼接的文件路径

string path = EditorUtility.SaveFilePanelInProject(“窗口标题”, “保存的文件的名称”, “后缀格式”, “在对话框窗口中显示的文本摘要”);

3.2 示例

using System.IO;
using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){// 显示文件存储面板(默认为工程目录中)if (GUILayout.Button("限制在当前 Unity 项目目录内选择或指定保存位置")){string str2 = EditorUtility.SaveFilePanelInProject("窗口标题", "测试文件2", "txt", "要在对话窗口中显示的文本摘要");// 只会从Asset开始拼接路径Debug.Log(str2);if (str2 != "") File.WriteAllText(str2, "内容2");}}
}

效果
在这里插入图片描述
在这里插入图片描述

五、其他

1、将 Texture2D 纹理压缩为指定的纹理格式

EditorUtility.CompressTexture 是 Unity 编辑器中的一个静态方法,用于显式地将 Texture2D 纹理压缩为指定的纹理格式。

public static void CompressTexture(Texture2D texture,TextureFormat format,TextureCompressionQuality quality
);

参数说明

  • texture (Texture2D): 需要压缩的纹理对象

  • format (TextureFormat): 目标压缩格式

    • 常用格式: TextureFormat.DXT1, TextureFormat.DXT5, TextureFormat.ETC2_RGBA8, TextureFormat.ASTC_4x4
  • quality (TextureCompressionQuality): 压缩质量

    • TextureCompressionQuality.Fast: 快速压缩,质量较低

    • TextureCompressionQuality.Normal: 正常压缩

    • TextureCompressionQuality.Best: 最佳质量,速度最慢

该知识点会配合之后的资源导入相关知识点使用

2、查找指定对象所依赖的所有资源

2.1 介绍

EditorUtility.CompressTexture 是 Unity 编辑器中的一个静态方法,,用于查找指定对象所依赖的所有资源

object[] EditorUtility.CollectDependencies(Object[] roots);

返回一个包含所有输入对象及其所有依赖项的 Object[] 数组。

2.2 示例

using UnityEditor;
using UnityEngine;public class TestEditorUtilityWindow : EditorWindow
{GameObject obj;[MenuItem("编辑器拓展/自定义窗口拓展/EditorUtility窗口拓展")]private static void OpenWindow(){TestEditorUtilityWindow win = EditorWindow.GetWindow<TestEditorUtilityWindow>();win.Show();}private void OnGUI(){obj = EditorGUILayout.ObjectField("想要查找关联资源的对象", obj, typeof(GameObject), true) as GameObject;if (GUILayout.Button("检索依赖资源") && obj != null){Object[] objs = EditorUtility.CollectDependencies(new Object[] { obj });// 用Selection类选中所有依赖的资源Selection.objects = objs;}}
}

效果
在这里插入图片描述


专栏推荐

地址
【unity游戏开发入门到精通——C#篇】
【unity游戏开发入门到精通——unity通用篇】
【unity游戏开发入门到精通——unity3D篇】
【unity游戏开发入门到精通——unity2D篇】
【unity实战】
【制作100个Unity游戏】
【推荐100个unity插件】
【实现100个unity特效】
【unity框架/工具集开发】
【unity游戏开发——模型篇】
【unity游戏开发——InputSystem】
【unity游戏开发——Animator动画】
【unity游戏开发——UGUI】
【unity游戏开发——联网篇】
【unity游戏开发——优化篇】
【unity游戏开发——shader篇】
【unity游戏开发——编辑器扩展】

完结

好了,我是向宇,博客地址:https://xiangyu.blog.csdn.net,如果学习过程中遇到任何问题,也欢迎你评论私信找我。

赠人玫瑰,手有余香!如果文章内容对你有所帮助,请不要吝啬你的点赞评论和关注,你的每一次支持都是我不断创作的最大动力。当然如果你发现了文章中存在错误或者有更好的解决方法,也欢迎评论私信告诉我哦!
在这里插入图片描述

http://www.dtcms.com/wzjs/315559.html

相关文章:

  • 阿里云网站建设教程seo网站排名优化服务
  • 扒完网站代码之后怎么做模板推广seo是什么意思
  • 装修平台加盟seo建站营销
  • 甜品店网站开发背景郑州短视频代运营公司
  • 监控安防的网站怎么做营销自动化
  • 网站建设计什么费用百度关键词在线优化
  • 网页设计代码html软件随州seo
  • 深圳营销型网站建设优化公司百度官网优化
  • mac网页制作软件优化二十条
  • 做旅游网站的开题报告成都网站建设方案托管
  • 网站制作成本百度竞价推广流程
  • 纪念币商城网站建设不属于网络推广方法
  • 企业微信营销系统辽宁seo推广
  • 宝鸡网站建设价格推广专员是做什么的
  • 网站上职业学校排名 该怎么做快速排名优化
  • 新网互联魔方手机网站建站系统自媒体账号申请
  • 昆山做网站的kamese站长之家域名查询
  • redhat7部署wordpress关键词搜索引擎优化推广
  • 网站建设开票税点郑州百度推广哪家好
  • 如何判断网站被google k西安seo整站优化
  • 深圳seo优化项目优化培训课程
  • 北京商场营业时间做优化关键词
  • 小网站发布要怎么做个人介绍网页制作
  • 网站如何做性能测试百度高级搜索引擎
  • 西安做网站哪里便宜商丘网络推广哪家好
  • 长春网站制作长春万网百度推广排名代发
  • 免费ppt模板的网站seo公司是什么意思
  • 在线商城开发费用搜索引擎优化员简历
  • 怎么做淘宝网站推广关键词搜索量全网查询
  • 宝安商城网站建设哪家便宜黄冈网站seo