Giter VIP home page Giter VIP logo

choicereferenceattribute's Introduction

ChoiceReferenceAttribute

This package allows you to use the [ChoiceReference] attribute to make a popup interaction to select a subclass from which the base class that you specified as the field type inherits. Lists and arrays are also supported, as is the fact that this attribute will be used again in subclasses.

Документация на русском

Add to project

To add this package to the project, follow these steps:

  1. Open PackageManager;
  2. Select "Add package from get URL";
  3. Insert links to packages that are dependencies of this package:
    • https://github.com/Paulsams/MiscUtilities.git
  4. Insert this link https://github.com/Paulsams/ChoiceReferenceAttribute.git

Related Packages

  1. RepairerSerializeReferences (so far only from 2021.2) - an editor window that allows you to fix links that flew due to a change in the name of the class, namespace, or assembly: https://github.com/Paulsams/RepairerSerializeReferences

Dependencies

Known Issues

  1. When editing objects multiple times and pressing the - button on a sheet/array (and only if this is not an SR array, but they are nested through other classes), errors may appear. There are no ideas yet, since the messages don’t even have a stack trace, but otherwise multiple editing works correctly.

Opportunities

  1. Works for lists/array and for any nesting of this attribute;

IMPORTANT: In order for the attribute to work for lists/array, it is necessary to add [System.Serializable] to the base class. Don't ask me why - that's life:

[SerializeReference, ChoiceReference] private BaseClass _singleChoiceReference;
[SerializeReference, ChoiceReference] private List<BaseClass> _listChoiceReferences;

image

  1. You can specify the nullable flag in the parameters attribute, which allows you to remove the "null" state from the selection for the object. If it is "false" (and this is the default value), then you will still need to select the type for the first time, otherwise there would be recursion if there is a field with the same attribute in the object.
[SerializeReference, ChoiceReference(true)] private BaseClass _singleChoiceReferenceNullable;
[SerializeReference, ChoiceReference] private BaseClass _singleChoiceReferenceNotNullable;

image

  1. ISerializeReferenceChangeValidate - an interface that you can implement at the heir in order to make some kind of check that the Type change is valid at the moment.
  2. When you click on + for lists, serialize references (nested through an additional class) are not copied (I have not yet seen this in any implementation of field attributes);
  3. Multiple object editing available.

Constructors

ChoiceReferenceAttribute(bool nullable)

Samples

To download the examples for this package:

  1. Select this package in PackageManager;
  2. Expand the "Samples" tab on the right;
  3. And click the "Import" button on the example you are interested in.

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.