在Unity开发游戏的时候,为了有一个更快更方便的工作流,我们往往会在Editor下开发一些方便实用的工具.在工具中,用到最多,最关键的就是按钮,它是工具的首席执行官.下面就用最简单的代码来演示添加一个自定义按钮到Inspector当中. 案例:指定坐标后克隆新物体到场景. 1. 在Unity Assets下创建”ObjectBuilderScript”脚本,添加代码: using UnityEngine; public class ObjectBuilderScript : MonoBeh
问题描述 游戏开发中会有多个场景,有时会有这样的需求,我们需要保证场景跳转但是需要保持某个游戏对象不被销毁,比如:音乐 实现思路 unity中提供了DontDestroyOnLoad(),这个API 使用这个指令一般写在跳转场景之前,写在跳转场景的触发事件中,把背景音乐绑定的对象做成预制体,上面绑定了播放音乐的代码 实现代码 using System.Collections; using System.Collections.Generic; using UnityEngine; using U
在扩展Unity的时候,往往会用到一些属性,这里将常用的列一下. 1.属性只读: #if UNITY_EDITOR using UnityEditor; #endif using UnityEngine; public class ReadOnlyAttribute : PropertyAttribute { } #if UNITY_EDITOR [CustomPropertyDrawer(typeof(ReadOnlyAttribute))] public class ReadOnlyDraw
AssetBundles are files which you can export from Unity to contain assets of your choice. These files use a proprietary compressed format and can be loaded on demand in your application. This allows you to stream content like models, textures, audio c
using UnityEngine; using System.Collections; using System.IO; using System.Net; using System; using UnityEditor; public class WWWLoad : MonoBehaviour { //string urlPath = "http://www....."; string urlPath = @"http://localhost:8080/fbx/test.
通过声明的变量名称,主动关联引用. 使用这个关联引用两种方式1. 给你组件继承 MonoAutoQuote 点击组件inspector 按钮执行2. 给你组件类添加[AAutoQuote] 特性 通过Plateface/SetSelectGameRef 执行 [AAutoQuote] public class MonoAutoQuote : MonoBehaviour ,IAutoQuote{} public interface IAutoQuote { } public class A
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
效果图如下: 今天一直在纠结如何加载场景,中间有加载画面和加载完毕的效果动画! A 场景到 B , 看见网上的做法都是 A –> C –> B. C场景主要用于异步加载B 和 播放一些加载场景的动画 AsyncOperation op = Application.LoadLevelAsync("C"); 异步加载C场景 op.allowSceneActivation = false; 加载完毕之后不自动跳转到B场景(在加载结束的时候,就可以播放一些加载完毕的动画)