Coder Social home page Coder Social logo

editorkit's Introduction

README

简介:

收集一些在工作中写的Utils

目录:

1.FloatRange
2.EnumFlags
3.EnumToInt
4.FolderPath
5.SortingLayer
6.AssetHash

FloatRange

很简单的一个结构体,写个属性方便编辑。

[System.Serializable]
public struct FloatRange
{
    public float min, max;
}

FloatRange_01

EnumFlags

通过给枚举加上[EnumFlags],从而可以实现多选。(例如像unity里面的Layer)
注意:需要复习一下二进制运算。

示例代码:

public enum TargetProperty
{
    Position        = 1<<0,
    Rotation        = 1<<1,
    Scale           = 1<<2,
    ClearFlags      = 1<<3,
    CullingMask     = 1<<4,
    FieldOfView     = 1<<5,
    NearClipPlane   = 1<<6,
    FarClipPlane    = 1<<7,
    Depth           = 1<<8
}

[EnumFlags]
public TargetProperty EnumFlagsExample;

EnumFlags_01

EnumToInt

通过给Int字段,加上[EnumInt(typeof(enum))],从而实现在Inspector中用户选择枚举类型,但是以Int的方式储存数据。

示例代码:

    [EnumToInt(typeof(EnumToIntExample))]
    public int enumToIntExample;

EnumToInt_01

FolderPath

通过给string字段,加上[FolderPath],从而实现在Inspector点击该字段,则跳出文件夹选择窗口。选择后,将路径保存在string字符串中。
示例代码:

    [FolderPath]
    public string folderPathExample;

FolderPath

SortingLayer

项目中经常需要序列化某个SortingLayer的值,手填Int操作十分麻烦,需要打开SortingLayer编辑面板,记住想要的值,再填。想要和ParticleSystem同样选SortingLayer的下拉框,Unity官方没有提供EditorGUI的接口,这里提供一个自己写的Attribute.
示例代码:

    [SortingLayer]
    public int SortingLayerExample;

SortingLayer

AssetHash

可以在Library创建一个Cache,记录资源是否变化,用于不同模块对比资源是否变化。

editorkit's People

Contributors

potrochen avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

editorkit's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.