我爱霍启刚掖 发表于 2021-2-22 09:20

Unity 插件 Odin

FilePath放到string变量上你会得到一个按钮,可以打开资源浏览器来选择文件,并且复制给这个字符串

public string ScenePath;
Button无参函数上,可以传入枚举,申明大小得到按钮,点击会调用该函数

public void SayHello()
{
    Debug.Log("Hello button!");
}
HideInInspector 和 ShowInInspector显示或隐藏到Inspector面板支持属性,没有序列化功能

public int NormallyVisible;


private bool normallyHidden;


public ScriptableObject Property { get; set; }
PreviewField可以预览GameObject

public GameObject Prefab;
Required放在可null参数上如string,如果为null,报错

public string username;
AssetsOnly可以申明GameObject的来源为Prefab,而不是Scenes

public GameObject Prefab;
PropertyOrder(数值)数值越低,越在上面,越高越在下面,可以负值

public GameObject Prefab;
HideLabel 隐藏标签PreviewField 设置大小HorizontalGroup 和 VerticalGroup水平布局和数值布局

public Texture2D Icon;


public string MinionName;


public float Health;


public float Damage;
LabelText 自定义标签

public string IAmLabel;
ListDrawSettings设置List的增加按钮和删除按钮的功能
[ListDrawerSettings(
    CustomAddFunction = "CreateNewGUID",
    CustomRemoveIndexFunction = "RemoveGUID")]
public List<string> GuidList;

private string CreateNewGUID()
{
    return Guid.NewGuid().ToString();
}

private void RemoveGUID(int index)
{
    this.GuidList.RemoveAt(index);
}
TabGroup 分组显示Inspector内容

public int FirstTab;


public int SecondTab { get; set; }


public float FloatValue;


public void Button()
{
        ...
}
复杂布局FoldoutGroup 和 HorizontalGroup 和 BoxGroup




public void Button1() { }



public void Button2() { }



public void Accept() { }



public void Cancel() { }
ValidateInput 验证输入传入函数,函数返回bool,如果为false,会在Inspector报错

public int GreaterThanZero;

private bool IsValid(int value)
{
        return value > 0;
}
OnValueChanged 只改变传入函数,值改变时调用

public GameObject Prefab;

private Rigidbody prefabRigidbody;

private void UpdateRigidbodyReference()
{
        if (this.Prefab != null)
        {
                this.prefabRigidbody = this.Prefab.GetComponent<Rigidbody>();
        }
        else
        {
                this.prefabRigidbody = null;
        }
}
InfoBox 信息盒子传入信息和函数,如果函数返回true,Inspector显示信息

public int MyInt;

private bool IsEven()
{
        return this.MyInt % 2 == 0;
}
@ 申明字符串为代码$property访问当前成员#能够引用范围内变量ShowIf 能够直接进行判断是否应该显示该字段

public string myStr;


public string myStr;


public string myStr;

public List<string> someList;


public bool expandList;
OdinEditorWindow 制作一个Window
public class SomeWindow : OdinEditorWindow
{
   
    private static void OpenWindow()
    {
      GetWindow<SomeWindow>().Show();
    }
       
   
   
   
    public void SomeButton1() { }

   
   
    public void SomeButton2() { }

   
   
    public void SomeButton3() { }

   
   
    public void SomeButton4() { }

   
   
    public void SomeButton5() { }

   
    public List<SomeType> SomeTableData;
}

public class SomeType
{
   
    public bool Toggle;

   
    public GameObject SomePrefab;

    public string Message;

   
   
    public void Test1() { }

   
    public void Test2() { }
}
页: [1]
查看完整版本: Unity 插件 Odin