In your component classes you can declare Blender properties that automatically sync their values with your linked component in Unity.
Declare your properties as annotations like you would for a Blender PropertyGroup.
from bpy.props import ( StringProperty, IntProperty, BoolProperty )
class MyComponent(Coherence.api.Component):
BoolVal: BoolProperty(name='Boolean Value')
IntVal: IntProperty(name='Int Value')
StrVal: StringProperty(name='String Value')
...
Properties you declare will be editable within your object's Coherence Components panel:
If you have a linked Unity component, properties that are updated in Blender will automatically set their matching C# properties in your component. By adding custom setter logic you can react to these property changes.
using UnityEngine;
using Coherence;
[ExecuteAlways]
[Component("MyComponent")]
public class MyComponent : MonoBehaviour, IComponent
{
public bool BoolVal { get; set; }
public int IntVal { get; set; }
public string StrVal {
get { return m_stringVal; }
set {
m_StringVal = value;
Debug.Log("Updated StrVal=" + value);
}
}
private string m_stringVal;
}
Important
Properties are currently one-way. Updating a property in Unity will not reflect those changes back in Blender.
Only a subset of Blender property types are currently supported: