在Unity开发游戏的时候,为了有一个更快更方便的工作流,我们往往会在Editor下开发一些方便实用的工具.在工具中,用到最多,最关键的就是按钮,它是工具的首席执行官.下面就用最简单的代码来演示添加一个自定义按钮到Inspector当中. 案例:指定坐标后克隆新物体到场景. 1. 在Unity Assets下创建”ObjectBuilderScript”脚本,添加代码: using UnityEngine; public class ObjectBuilderScript : MonoBeh
在扩展Unity的时候,往往会用到一些属性,这里将常用的列一下. 1.属性只读: #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; public class ReadOnlyAttribute : PropertyAttribute { } #if UNITY_EDITOR [CustomPropertyDrawer(typeof(ReadOnlyAttribute))] public class ReadOnlyDraw
通过声明的变量名称,主动关联引用. 使用这个关联引用两种方式1. 给你组件继承 MonoAutoQuote 点击组件inspector 按钮执行2. 给你组件类添加[AAutoQuote] 特性 通过Plateface/SetSelectGameRef 执行 [AAutoQuote] public class MonoAutoQuote : MonoBehaviour ,IAutoQuote{} public interface IAutoQuote { } public class A
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PauseContorl : MonoBehaviour { bool isGamePause; //游戏暂停按钮 private GameObject pauseButtonObj; //当前暂停按钮的图片 private Image currentPauseImage
1.首先在相应的位置添加一个(UGUI控件)image,在image下添加文本框和按钮设计弹出框内容如图: 2.新建C#脚本UITips using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UITips : MonoBehaviour { public static Vector3 vec3, pos; // Use th
在做项目时,比如声音开关我们涉及到按钮的图标切换. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using RenderHeads.Media.AVProVideo; public class SoundButton : MonoBehaviour { /// <summary> /// 要设置的图集 /// </summary&g