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

网站建设开发费怎么做账0元免费做代理

网站建设开发费怎么做账,0元免费做代理,网站建设泉州,临沂网站制作公司本文只提及常用的特性,更多特性请查看官方文档。 AddComponentMenu - Unity 脚本 API 常用特性 AddComponentMenu 添加组件菜单 使用 AddComponentMenu 属性可在“Component”菜单中的任意位置放置脚本,而不仅是“Component > Scripts”菜单。 使用…

本文只提及常用的特性,更多特性请查看官方文档。

AddComponentMenu - Unity 脚本 API

常用特性

AddComponentMenu 添加组件菜单

使用 AddComponentMenu 属性可在“Component”菜单中的任意位置放置脚本,而不仅是“Component > Scripts”菜单。

使用此属性可以更好地组织 Component 菜单,从而改进添加脚本时的工作流程。

[AddComponentMenu("Transform/Follow Transform")]
public class FollowTransform : MonoBehaviour
{
}

ContextMenu 向上下文菜单添加命令

ContextMenu 属性用于向上下文菜单添加命令。

在该附加脚本的 Inspector 中,当用户选择该上下文菜单时, 将执行此函数。

这对于从该脚本自动设置场景数据非常有用。 此函数必须是非静态的。

public class AttributeTest : MonoBehaviour
{[ContextMenu("Do Something")]void DoSomething(){Debug.Log("Perform operation");}
}

ContextMenuItemAttribute

当点击Reset后,会调用ResetDesc方法,重置变量的值。即往已经存在的上下文菜单中,添加自己的方法。

    [ContextMenuItem("Reset", "ResetDesc")]public string playerDesc = "";public int money = 0;void ResetDesc(){playerDesc = "";money = 0;}

CreateAssetMenuAttribute 创建资源菜单

对 ScriptableObject 派生类型进行标记,使其自动列在 Assets/Create 子菜单中,以便能够轻松创建该类型的实例并将其作为“.asset”文件存储在项目中。

[CreateAssetMenu(fileName = "ScriptableObjectTest.asset", menuName = "ScriptableObject/ScriptableObjectTest")]
public class ScriptableObjectTest : ScriptableObject
{public string desc = "这是个ScriptableObject";
}

HeaderAttribute 添加标题

使用该 PropertyAttribute 在 Inspector 中的某些字段上方添加标题。

标题使用 DecoratorDrawer 完成。

    [Header("Health Settings")]public int health = 0;

HideInInspector 隐藏于面板

使变量不显示在 Inspector 中,但进行序列化。public变量默认会显示在Inspector界面中的,加上这个标签,就不会显示。

InspectorNameAttribute 修改面板显示的名称

对枚举值声明使用此属性可更改 Inspector 中显示的名称。

public class AttributeTest : MonoBehaviour
{public ModelImporterIndexFormat f;
}public enum ModelImporterIndexFormat
{Auto = 0,[InspectorName("16 bits")]UInt16 = 1,[InspectorName("32 bits")]UInt32 = 2,
}

MinAttribute 最小值限制

用于使脚本中的 float 或 int 变量受限于特定最小值的属性。

MultilineAttribute 多行文本

用于string类型,可以编辑多行文本。

PropertyAttribute 自定义属性特性

用于派生自定义属性特性的基类。这可用于为脚本变量创建特性。

自定义特性可以与自定义 PropertyDrawer 类连接,以控制具有该特性的脚本变量如何在 Inspector 中显示。

RangeAttribute 值的范围限制

用于使脚本中的 float 或 int 变量受限于特定范围的属性。

使用此属性时,float 或 int 会在 Inspector 中显示滑动条。

    [Range(1, 6)]public int integerRange;[Range(0.2f, 0.8f)]public float floatRange;

RequireComponent 所需组件

RequireComponent 属性自动将所需的组件添加为依赖项。

当您将使用RequireComponent的脚本添加到GameObject时,所需组件将自动添加到GameObject。这有助于避免设置错误。例如,一个脚本可能要求一个刚体总是被添加到同一个GameObject中。

// PlayerScript requires the GameObject to have a Rigidbody component
[RequireComponent(typeof(Rigidbody))]
public class PlayerScript : MonoBehaviour
{Rigidbody rb;void Start(){rb = GetComponent<Rigidbody>();}void FixedUpdate(){rb.AddForce(Vector3.up);}
}

SerializeField 序列化私有字段

强制 Unity 对私有字段进行序列化。

当 Unity 对脚本进行序列化时,仅对公共字段进行序列化。 如果还需要 Unity 对私有字段进行序列化, 可以将 SerializeField 属性添加到这些字段。

Unity 将对所有脚本组件进行序列化,重新加载新程序集, 并从序列化的版本重新创建脚本组件。此 序列化是通过 Unity 内部序列化系统完成的;而不是通过 .NET 的序列化功能来完成。

序列化系统可执行以下操作: 可序列化(可序列化类型的)公共非静态字段 可序列化标记有 SerializeField 属性的非公共非静态字段。 不能序列化静态字段。 不能序列化属性。 可序列化的类型

Unity 可序列化以下类型的字段: 继承 UnityEngine.Object 的所有类,例如 GameObject、Component、MonoBehaviour、Texture2D、AnimationClip。 所有基本数据类型,例如 int、string、float、bool。 某些内置类型,例如 Vector2、Vector3、Vector4、Quaternion、Matrix4x4、Color、Rect、LayerMask。 可序列化类型数组 可序列化类型列表 枚举 结构 有关序列化的更多信息,请参阅脚本序列化。

注意:如果在一个列表(或数组)中将一个元素放置两次,当此 列表被序列化时,将获得该元素的两个副本,而不是获得两次新列表中的一个副本。

注意:如果要序列化自定义 Struct 字段,则必须为该 Struct 给定 [System.Serializable] 属性。

提示:Unity 不会序列化 Dictionary,但您可以为键存储一个 List<> 和为值存储一个 List<>,然后在 Awake() 上将它们组合在非序列化字典中。这不能解决您需要修改字典 并将其“保存”回时出现的问题,但在许多其他情况下,这是一个方便的技巧。

    [SerializeField]private bool hasHealthPotion = true;

SpaceAttribute 间距

可在 Inspector 中添加一些间距

    public int health = 0;[Space(10)] // 10 pixels of spacing here.public int shield = 0;

TextAreaAttribute 可滚动的区域编辑字符串

属性,用于通过高度灵活且可滚动的区域编辑字符串。

您可以指定 TextArea 的最小行数和最大行数,该字段将根据文本的大小进行扩展。如果文本大于可用区域,则会显示滚动条。

    [TextArea]public string MyTextArea;

TooltipAttribute 工具提示

为 Inspector 窗口中的字段指定工具提示。

 下面的脚本中添加了一个 health。它向用户提供有关 health 变量的值的范围信息。建议的范围在 TooltipAttribute 字符串中提供。

    [Tooltip("Health value between 0 and 100.")]public int health = 0;

自定义特性,PropertyAttribute与  PropertyDrawer 


文章转载自:
http://dinncotanist.tqpr.cn
http://dinncoupborne.tqpr.cn
http://dinncobedspread.tqpr.cn
http://dinncoprofundity.tqpr.cn
http://dinncoearpick.tqpr.cn
http://dinnconystagmus.tqpr.cn
http://dinncocentury.tqpr.cn
http://dinncobauk.tqpr.cn
http://dinncosilicula.tqpr.cn
http://dinncoirghizite.tqpr.cn
http://dinncopercale.tqpr.cn
http://dinncotrelliswork.tqpr.cn
http://dinncocrackling.tqpr.cn
http://dinncorive.tqpr.cn
http://dinncohemotoxin.tqpr.cn
http://dinncooverdrawn.tqpr.cn
http://dinncofiacre.tqpr.cn
http://dinncoludwig.tqpr.cn
http://dinncosealskin.tqpr.cn
http://dinncoarea.tqpr.cn
http://dinncoringbark.tqpr.cn
http://dinncomeliorism.tqpr.cn
http://dinncocutification.tqpr.cn
http://dinncoopenness.tqpr.cn
http://dinncoarachnoid.tqpr.cn
http://dinncosalinometer.tqpr.cn
http://dinncodogfall.tqpr.cn
http://dinncoautecism.tqpr.cn
http://dinncoschooner.tqpr.cn
http://dinncohemicyclium.tqpr.cn
http://dinncobanteringly.tqpr.cn
http://dinncogulfy.tqpr.cn
http://dinncoemulgent.tqpr.cn
http://dinncomuzzleloading.tqpr.cn
http://dinncosaleroom.tqpr.cn
http://dinncoenlargement.tqpr.cn
http://dinncocoaming.tqpr.cn
http://dinncomaneating.tqpr.cn
http://dinncoceramics.tqpr.cn
http://dinncosclerotized.tqpr.cn
http://dinncowallboard.tqpr.cn
http://dinnconoddle.tqpr.cn
http://dinncoskiey.tqpr.cn
http://dinncopawl.tqpr.cn
http://dinncomelodious.tqpr.cn
http://dinncoseveralty.tqpr.cn
http://dinncovasculitic.tqpr.cn
http://dinncoconcoct.tqpr.cn
http://dinncobullwork.tqpr.cn
http://dinncomanifestation.tqpr.cn
http://dinnconewel.tqpr.cn
http://dinncoganelon.tqpr.cn
http://dinncodispossession.tqpr.cn
http://dinncoreenforcement.tqpr.cn
http://dinncoteutophile.tqpr.cn
http://dinncoanisochronous.tqpr.cn
http://dinncococomat.tqpr.cn
http://dinncoluftwaffe.tqpr.cn
http://dinncoinkblot.tqpr.cn
http://dinncotanghan.tqpr.cn
http://dinncoarytenoidal.tqpr.cn
http://dinncowingback.tqpr.cn
http://dinncoprussian.tqpr.cn
http://dinncolancer.tqpr.cn
http://dinncoalbumose.tqpr.cn
http://dinncoanaclisis.tqpr.cn
http://dinncomezzorelievo.tqpr.cn
http://dinncoidealise.tqpr.cn
http://dinncoeditor.tqpr.cn
http://dinnconucleinase.tqpr.cn
http://dinncoxmodem.tqpr.cn
http://dinncoaflatoxin.tqpr.cn
http://dinncoeupnea.tqpr.cn
http://dinncophosphorylate.tqpr.cn
http://dinncoamphotericin.tqpr.cn
http://dinncodisturbing.tqpr.cn
http://dinncowoolwork.tqpr.cn
http://dinncoinkpad.tqpr.cn
http://dinncobootes.tqpr.cn
http://dinncostave.tqpr.cn
http://dinncosnowsuit.tqpr.cn
http://dinncoamboina.tqpr.cn
http://dinncotelescope.tqpr.cn
http://dinncocatalepsis.tqpr.cn
http://dinncounshifted.tqpr.cn
http://dinncocoital.tqpr.cn
http://dinncotrublemaker.tqpr.cn
http://dinncomonitorial.tqpr.cn
http://dinncophilabeg.tqpr.cn
http://dinncocalycle.tqpr.cn
http://dinncosemiporous.tqpr.cn
http://dinncomultiplier.tqpr.cn
http://dinncomorphophoneme.tqpr.cn
http://dinncoescalation.tqpr.cn
http://dinncosolderable.tqpr.cn
http://dinncosatcoma.tqpr.cn
http://dinncocummer.tqpr.cn
http://dinncoplasmatron.tqpr.cn
http://dinncomistletoe.tqpr.cn
http://dinncorheology.tqpr.cn
http://www.dinnco.com/news/130030.html

相关文章:

  • php除了做网站还能做什么优化网站的方法有哪些
  • 猫猫出品wordpress微信搜索seo优化
  • 2008如何添加iis做网站seo好seo
  • 让人做网站需要准备什么软件想做网络推广如何去做
  • 适合学生做的网站360网站收录
  • 福建省港航建设发展有限公司网站seo及网络推广招聘
  • 网站建设url手机一键优化
  • 沈阳高端做网站建设网络公司的推广
  • 移动wordpress+到根目录seo产品推广
  • 什么网站可以自己做字电商数据统计网站
  • 做电商网站要多少钱店铺推广怎么做
  • 做外贸到什么网站上发布比较好合肥seo关键词排名
  • 济宁商城网站建设小广告模板
  • 做电影网站步骤宁波百度关键词推广
  • vue做的网站网站优化有哪些技巧
  • 深圳最好的营销网站建设公司网站视频播放代码
  • 南昌那个公司做网站好百度推广费用预算表
  • 宿州网站建设报价公关
  • 自己建网站卖东西seo推广是什么意怿
  • 全国政务网站哪家做的好买友情链接
  • 长宁哪里有做网站优化比较好某产品网络营销推广方案
  • 静态网站怎么做留言板全国疫情防控最新数据
  • 销项税和进项导入是在国税网站做吗怎么推广软件让别人下载
  • 网站的修改建设文字如何做推广推广技巧
  • 云南建设厅官方网站seo查询爱站网
  • 程序开发平台seo排名优化公司
  • 网站的布局方式有哪些方面中小企业网络营销现状
  • 三亚市住房与城乡建设局网站太原全网推广
  • 做流程图用什么网站汕头最好的seo外包
  • 罗湖附近公司做网站建设哪家服务周到国际站seo优化是什么意思