首页 > 其他分享 >Unity-NaughtAttributes

Unity-NaughtAttributes

时间:2023-04-05 16:58:13浏览次数:31  
标签:myInt int private Unity bool NaughtAttributes EnableIf public

Special Attributes

AllowNesting

Struct需要嵌套时使用

Drawer Attributes

Animator显示下拉参数

public Animator someAnimator;

[AnimatorParam("someAnimator")]
public int paramHash;

Button直接执行函数

[Button("Button Text")]
private void MethodTwo() { }

AnimationCurves

[CurveRange(0, 0, 5, 5, EColor.Red)]
public AnimationCurve curve2;
[Dropdown("intValues")]
public int intValue;
private int[] intValues = new int[] { 1, 2, 3, 4, 5 };

EnumFlags

public enum Direction
{
  None = 0,
  B = 1 << 0,
  C = 1 << 1,
  D = 1 << 2,
  E = 1 << 3,
  F = 1 << 4,
  G = 1 << 5,
  H = 1 << 6,
  I = 1 << 7,
  J = 1 << 8,
  k = 1 << 9,
  All = ~0
}

public class NaughtyComponent : MonoBehaviour
{
	[EnumFlags]
	public Direction flags;
}

Expandable

ScriptableObject可展开

HorizontalLine(height, color)

分割线

InfoBox

信息提示框

[InfoBox("Normal", EInfoBoxType.Normal)]

[InfoBox("Warning", EInfoBoxType.Warning)]

[InfoBox("Error", EInfoBoxType.Error)]

InputAxis

输入系统下拉框

[InputAxis]
public string inputAxis0;

Layer/SortingLayer/Tag

层级下拉[Layer][SortingLayer]

支持string layername和int layerindex

MinMaxSlider

[MinMaxSlider(0.0f, 100.0f)]
public Vector2 minMaxSlider;

ProgressBar进度条

[ProgressBar("Health", 300, EColor.Red)]

ReorderableList

可重排序list, [ReorderableList]

ShowAssetPreview

显示Sprite, Prefab,Texture缩略图

ShowNativeProperty

显示属性,仅支持以下类型

bool, int, long, float, double, string, Vector2, Vector3, Vector4, Color, Bounds, Rect, UnityEngine.Object;

Nest中无法显示属性;

属性显示的顺序在字段后;

ShowNonSerializedField

显示私有字段,且使其不可更改;

Meta Attributes元组属性

BoxGroup

[BoxGroup("Integers")]
public int firstInt;
[BoxGroup("Integers")]
public int secondInt;

Foldout

[Foldout("Integers")]
public int firstInt;
[Foldout("Integers")]
public int secondInt;

EnableIf / DisableIf

public bool enableMyInt;

[EnableIf("enableMyInt")]
public int myInt;

[EnableIf("Enabled")]
public float myFloat;

[EnableIf("NotEnabled")]
public Vector3 myVector;

public bool Enabled() { return true; }

public bool NotEnabled => false;

//多个条件
public bool flag0;
public bool flag1;

[EnableIf(EConditionOperator.And, "flag0", "flag1")]
public int enabledIfAll;

[EnableIf(EConditionOperator.Or, "flag0", "flag1")]
public int enabledIfAny;

ShowIf / HideIf

public bool showInt;

[ShowIf("showInt")]
public int myInt;

Label

[Label("Short Name")]
public string veryVeryLongName;

OnValueChanged

[OnValueChanged("OnValueChangedCallback")]
public int myInt;

private void OnValueChangedCallback()
{
	Debug.Log(myInt);
}

ReadOnly

[ReadOnly]
public Vector3 forwardVector = Vector3.forward;

Validator Attributes

MinValue / MaxValue

[MinValue(0), MaxValue(10)]
public int myInt;

[MinValue(0.0f)]
public float myFloat;

Required

[Required]
public Transform myTransform;

[Required("Custom required text")]
public GameObject myGameObject;

ValidateInput

[ValidateInput("IsNotNull")]
public Transform myTransform;

[ValidateInput("IsGreaterThanZero", "myInteger must be greater than zero")]
public int myInt;

private bool IsNotNull(Transform tr)
{
	return tr != null;
}

private bool IsGreaterThanZero(int value)
{
	return value > 0;
}

标签:myInt,int,private,Unity,bool,NaughtAttributes,EnableIf,public
From: https://www.cnblogs.com/littleperilla/p/17289733.html

相关文章

  • Unity 字体研究
    在学习公司项目的时候看到有的字体定义了内容  和以前我看见其他人提出的问题,“热更框架之外,用到了字体文件,热更里也有使用字体文件,如何去重。”我对这个问题印象深刻,今天看见项目如此操作估计就是想解决这个问题利用字体压缩工具 https://github.com/forJrking/FontZip......
  • Unity升级后打包AssetBundle变慢
    1)Unity升级后打包AssetBundle变慢​2)打包使有些资源合成了一个资源data.unity3d,有些分开的原因3)Unreal在移动设备中无法使用Stat命令获取到GPUThread的耗时4)Unity中如何看到相机视野范围内的剔除结果这是第330篇UWA技术知识分享的推送,精选了UWA社区的热门话题,涵盖了UWA问答、社......
  • Unity
    找不到progrids,使用git远程安装https://stackoverflow.com/questions/67119431/unity-3ds-package-manager-is-not-showing-progrids-module......
  • re/【unity】游戏逆向首试 [BJDCTF2020]BJD hamburger competition
    本题是是一个unity游戏,而且是以c#和.net编写尝试直接用idea进行反汇编,但是没有找到运行逻辑,后来在大佬的wp上发现是利用dnspy对c#的dll文件进行返回编,进而获得结果。反汇编BJDhanburgercompetirion_Data中的Assembly-CSharp.dll即可获得如下代码段:可以看到先利用sha1进行加......
  • Unity客户端开发工程师的进阶之路
    UWA技能成长系统是UWA根据学员的职业发展目标,提供技能学习的推荐路径,再将所需学习内容按难易等多维度,设计分成多个学习阶段,可以循序渐进地进行学习。每个阶段学员完成学习任务后不但可以获得技能的提升,还将获得UWA社区相应的积分奖励(积分可兑换礼品和优惠券哦)。 进入技能成长......
  • unity3d面试题及答案
    unity3d面试题及答案1.请描述游戏动画有哪几种,以及其原理。答:主要有关节动画、单一网格模型动画(关键帧动画)、骨骼动画。    关节动画把角色分成若干独立部分,一个部分对应一个网格模型,部分的动画连接成一个整体的动画,角色比较灵活Quake2中使用了这种动画;   单一网......
  • unity学习——c#初级编程
    1.作为行为组件的脚本首先新建一个cube立方体  然后新建一个c#脚本,脚本用来实现立方体cube的三种颜色变化(按键实现)  脚本代码如下:usingUnityEngine;usingSystem.Collections;publicclasscolor:MonoBehaviour{voidUpdate(){if(Input.GetKeyD......
  • Spine在Unity 的URP模式下,描边的坑。
    在urp模式下,spine描边需要特殊处理,首先去。官网下载他们的urp拓展包,然后通过packagemanager导入到项目。打开包里outlineshadersurp场景。发现他们实现这个场景的时候,是在spine动画下面套了一个outline对象,这个outline对象有一个脚本叫做renderexistingmesh。将这个脚本......
  • Unity实现物件选中效果
    首先制作两个显示效果,一个是未被选中时的物件(Visual),一个是被选中时的物件(Focused)。然后将这两个gameObject挂载到父节点上。创建C#代码CounterFocused添加为父节点的组件。publicclassCounterFocused:MonoBehaviour{[SerializeField]privateGameObjectNor......
  • unity [数学] 四元数和Vector3相乘的意义
    参考:https://answers.unity.com/questions/186252/multiply-quaternion-by-vector.html 总结:Quaternion*Vector3表示在世界坐标系下,Vector3的任意旋转; Inthequaternionworld,multiplicationisthewaytoapplytherotationtosomething  【在Quaternion下,相......