Giter Club home page Giter Club logo

attributes's Introduction

Attributes

  • Property attributes for Unity fields
  • Unity minimum version: 2020.3
  • Current version: 3.0.0
  • Licence: MIT

Summary

How To Use

Just use one of the following attributes:

  • AssetsOnly: only select assets references.
  • Required: use it on strings, exposed and object reference types. If the value is null or empty, an error message will be displayed on Inspector bellow the given attribute.
  • Tag: use it only with string fields. It'll replace the string field by a tag popup.
  • DisableInPlayMode: use this to prevent users from editing a property when in play mode.
using UnityEngine;
using ActionCode.Attributes;

public sealed class TestBehaviour : MonoBehaviour
{
    [AssetsOnly(typeof(GameObject))] public GameObject player;
    [Required] public string playerId;
    [Tag] public string playerTag = "Player";
}

Attributes

  • ShowIf: use it to show properties based on the current state of the object.
using ActionCode.Attributes;

public sealed class TestBehaviour : MonoBehaviour
{
    [Range(0, 20)] public int powerLevel;
    [ShowIf("powerLevel", LogicalOperatorType.GreaterOrEqual, 10)]
    public string powerLevelName = "Super Power";
}

Show If Attribute Showcase

  • ReadonlyIf: use it to disallow changes in properties based on the current state of the object.
using ActionCode.Attributes;

public sealed class TestBehaviour : MonoBehaviour
{
    public RigidbodyConstraints2D constraint;
    [ReadonlyIf("constraint", RigidbodyConstraints2D.FreezePositionX)]
    public float forceX = 10F;
}

Readonly If Attribute Showcase

  • CreateButton: use it to add a Create Button next to a ScriptableObject field if no reference is set.
using ActionCode.Attributes;

public sealed class TestBehaviour : MonoBehaviour
{
    [CreateButton(typeof(SceneTransition))]
    public SceneTransition defaultTransition;
}

Create Button Attribute Showcase

Installation

Using the Package Registry Server

Follow the instructions inside here and the package ActionCode-Attributes will be available for you to install using the Package Manager windows.

Using the Git URL

You will need a Git client installed on your computer with the Path variable already set.

  • Use the Package Manager "Add package from git URL..." feature and paste this URL: https://github.com/HyagoOliveira/Attributes.git

  • You can also manually modify you Packages/manifest.json file and add this line inside dependencies attribute:

"com.actioncode.attributes":"https://github.com/HyagoOliveira/Attributes.git"

Hyago Oliveira

GitHub - BitBucket - LinkedIn - [email protected]

attributes's People

Contributors

hyagooliveira avatar

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.