VectorFocus
Set your position data with a click
|
This package allows you to select the positions (vector2 and vector3) with or without array of your scriptable objects and monobehaviours using a simple click on your scene.
It also has these features:
Will become :
The first button corresponds to the "pointer" mode, which is the default mode, it displays the field values on the scene using the GUI. When clicking on the scene, the field value automatically changes to the mouse position.
The second button corresponds to the 'gameObject' mode, the values are displayed by creating a gameObject (one per value), they are displayed in the hierarchy (at the bottom), each of them is positioned according to the value of its field. If you change its position, the value of the field will be automatically updated.
If you are in "gameObject" mode and the selected field is an array or a list, an additional button will appear to the right of the "gameObject" mode button. It allows to display the other vectors composing the array for an overview. This mode is not activated by default for performance reasons (an array composed of thousands of elements could slow down the editor)
The last button allows you to quit editing your field, clicking on another field or closing the inspector will do the same.
To start you will need to associate the VectorFocus attribute to your field.
Once done you can open the configuration via the menu: window/VectorFocus/Configuration
.
The configuration allows you to modify the preview of the values in "pointer" or "gameObject" mode.
You can then modify the configuration it will be applied only on this field.
Description of the configuration fields:
When selecting a multiple field (array or list), all the elements can be displayed, those that do not come from the selected field will use the configurations with the word Others in suffix.
TextColor: Text color.
Text Color Others: Text color of an unselected element.
Font Size: Font size.
Font Size Others: Font size of an unselected item.
Scale: Scale of the shape.
Scale Others: Scale of the shape of an unselected element.
Shape: Shape used to represent the vector.
Shape Others: Shape used to represent the vector of a non selected element.
Shape Color: Color of the shape.
Shape Color Others: Color of the shape of an unselected item.
Sprite: Sprite of the gameObject.
SpriteOrderInLayer: Order in layer of the sprite.
Property Path Sprite: Property Path to load the sprite.
Sprite Color: Color of the sprite.
Sprite Color Others: Color of the sprite of a not selected element.
Prefab: Prefab replacing the sprite.
Scale: Scale of the gameObject.
Scale Others: Scale of the gameObject of an unselected element.
Rotation: Rotation of the gameObject.
For the Property Path Sprite field you must fill in the propertyPath of a Sprite field attached to your entity.
At the technical level each field configuration is an instance of the VectorFocus.ConfigSkin.AbstractSkinVector
class.
You can override the configuration of a field by creating a class inheriting from VectorFocus.ConfigSkin.AbstractSkinVector
Example:
Then on your vector field you can force the use of your skin :
By going back to your skin you can override the methods to change the configuration :
If a method is not overridden or if we return null, the skin used will be the one of the configuration, if no skin is defined it will use the default skin VectorFocus.ConfigSkin.SkinVector.Default
After overloading a skin, it is possible to use a callback to fully modify the gameobject generated in "gameObject" mode.
In this example we will animate (turn on itself) the selected gameObject.
Important information, at each instantiation of gameObject during a preview, the component FocusBehaviour will be attached to the gameObject. This component inherits from Monobehaviour, it is used to sync the position of the gameObject with its selected field and to display the design according to the configuration.
First we have to create a class inheriting from the VectorFocus.IFocusBehaviourCallback interface
Then define this callback in the configuration overload
We can now take care of animating our gameObject.
The OnInit method of the callback is called last, after the skin is applied.