Skip to content

Property inheritance

Nectunia edited this page Oct 27, 2020 · 7 revisions

In some case you will need to make your own Property component. To understand how to do that, you can check the source code of Property2 or Property3 components.
You can find them in your Unity Project tab : "Assets/Plugins/Nectunia/PropertyInterface/Package/Scripts/Components/".

To create a component wich will be able to interact with Property, see Create your Tagged component instead.

Example class

Bellow you will find an example that do nothing more than Property component but implements all you need to make your own Property child:

using UnityEngine;
using System;
using Nectunia.PropertyInterface;

/// <summary>
/// My new Property component
/// </summary>
[Serializable]
public class MyProperty : Property {            
    // Add your attributs here. Don't forget to add [SerializeField] for thoose wich need to be drawn in Editor
    // ...

    /// <summary>
    /// Set the Tag.ValueType for all PropertyValue.
    /// </summary>
    public override void SetValuesType () {
        base.SetValuesType();
    }

    /// <summary>
    /// Set a new Property.SourceType for all PropertyValue.
    /// </summary>
    /// The new Property.SourceType.
     protected override void SetValuesSourceType (SourceType newType) {
        base.SetValuesSourceType(newType);
    }
    
    /// <summary>
    /// Set a new Component for all PropertyValue.
    /// </summary>
    /// The new Component.
    protected override void SetValuesComponent (Component newComponent) {
        base.SetValuesComponent(newComponent);
    }    
    
    /// <summary>
    /// Refresh all object values with the serializedValues.
    /// </summary>
    public override void RefreshValuesObject () {
        base.RefreshValuesObject();
    }

    /// <summary>
    /// Synchronize the values with their sources if need.
    /// </summary>
    public override void SynchronizeValues () {
        base.SynchronizeValues();
    }
    
    /// <summary>
    /// Check if the sources of the values are set or not.
    /// </summary>
    ///
    /// True if at least one value.Source is set. False otherwise.
    ///
    public override bool AtLeastOneSourceIsSet () {
        return base.AtLeastOneSourceIsSet();
    }
}

Clone this wiki locally