一. 参数自定义 一个含有成员的类Player using System.Collections; using System.Collections.Generic; using UnityEngine; public class Player : MonoBehaviour { public int id; public string playerName; public string backStory; public float health; public float damage; p
当我们在编辑界面要批量设置游戏资源的时候,就需要从UnityEditor里面继承,实现自己的窗口类. 所幸UNITY提供了最简单的一个自定义窗体类,我们直接往上扔public类型的属性就好,提供了确认和取消两种按钮. using UnityEngine; using System.Collections.Generic; using UnityEditor; public class Plugin_LoadingData : ScriptableWizard { [MenuItem ("Game
1.为什么在Inspector视图中有的脚本前面有勾选框,有的脚本前面没有? 当我想要禁用一个脚本时,发现脚本前面没有勾选框,有的却有. 解决办法:在脚本中添加start方法,然后就有勾选框了. 原因:不明. 2.禁用脚本后发现脚本中的代码仍然在运行,为什么呢? 类似于OnTriggerEnter()的事件监听方法在脚本被禁用后,仍然会执行. 原因:不明.或许了解下这类方法执行的原理有助于知道为什么. 3.C#属性简写的原理分析: private int fish; public int Fis
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEditor; using System; [ExecuteInEditMode] [CustomEditor(typeof(testxx))] public class testxxEditor : Editor { [SerializeField] public float slider_value = 0.3f;
有如下两种方式,第一种借助了Unity自身的LogType枚举型:第二种则是纯粹地自己定义: public class Log { public Log(string message, UnityEngine.LogType logType = LogType.Log) { switch (logType) { case LogType.Log: UnityEngine.Debug.Log(message); break; case LogType.Warning: UnityEngine.De
using UnityEngine;using UnityEditor;using System.Collections;using System.IO;using System.Collections.Generic; public class SetTools{ [MenuItem("Custom/SetMaterrial")] public static void SetMaterrial() { foreach (GameObject volumeGo in Selection
using UnityEditor;using UnityEngine;using CreateTerrainDLL; public class CreateTerrainMenu : EditorWindow{ [MenuItem("CreateTerrainMenuItem/CreatTerrain")] public static void OpenTerrainCreatWindow() { EditorWindow.GetWindow(typeof(CreateTerrain
public class MyClass : MonoBehaviour { public int A; // Use this for initialization void Start () { } // Update is called once per frame void Update () { } } using UnityEngine; using System.Collections; using UnityEditor; [CanEditMultipleObjects()] [