-
Notifications
You must be signed in to change notification settings - Fork 0
Create my tagged component
It's pretty simple to create a tagged component :
- Create you own class wich inherite from MonoBehaviourTagged.
- Make sure that your component can find Property components or find MonoBehaviourTagged components it needs to interact with.
- Script the mechanic you want to implement.
- (Optional) Make a custom Editor if need.
As an advanced example you can have a look at the PropertyTriggerHandler component available in this asset. It can be find in the Unity editor Project tab : "Assets/Plugins/Nectunia/PropertyInterface/Package/Scripts/Components/"
Inherite MonoBehaviourTagged
When inherite from MonoBehaviourTagged, you can catch the triggers onValuesTypeChanged() and OnTagIDChanged(). Below an example class :
using Nectunia.PropertyInterface;
using System;
using UnityEngine;/// <summary>
/// My custom tagged component
/// </summary>
public class MyCustomTaggedComponent : MonoBehaviourTagged{
public string _tagTypeName;
[SerializeField]
private Property _attachedProperty;public void Update () {
// Property component have only 1 value => it's name "A"
// Here we log its value in the console
Debug.Log("The value of the attached Property is : " + this._attachedProperty?.A.Value.ToString());
}/// <summary>
/// Event triggered when this.TagID changed.
/// </summary>
protected override void OnTagIDChanged () {
// Get in the current GameObject the first Property component wich refer the same TagID
this._attachedProperty = this.gameObject.GetProperty(this.TagID);
}/// <summary>
/// Event triggered when this.ValuesType changed.
/// </summary>
protected override void OnValuesTypeChanged () {
// Get the Type name of the refered Tag's ValueType
this._tagTypeName = this.ValuesType.GetSystemType().Name;// Another solution
//this._tagTypeName = Enum.GetName(typeof(Tag.ValueType), this.ValuesType);
}
}
MonoBehaviourTagged provide a default Editor wich draw its fields and those of its children.
Here the default Editor for the above custom tagged component example :

Home
First look
What about performance ?
Tag
Tag overview
Export Tags
Import Tags
Property
Property overview
Setting a Property
Property Updater
Property inheritance
Find Property by script
Editor GUI
EditorGUI_PropertyInterface
EditorGUILayout_PropertyInterfac
MonoBehaviourTagged
Tagged component overview
Built in tagged component
Create my tagged component
Find MonoBehaviourTagged by script
Error
Null propagating operator
Scripting
Classes descriptions