Behaviour Vars provides named values and reusable conditions for Unity packages. ILayer exposes values; runtime code copies them into a RuntimeValueCollection for evaluation.
Package id: com.deathbygravitystudio.behaviour.vars (0.1.0). Assemblies: Behaviour.Vars and Behaviour.Vars.Editor. Runtime types live in Behaviours and Behaviours.Runtime.
- Named values.
Valueis aScriptableObjectwith a name, aValueType, and storage for a bool (bValue), int (iValue), float (fValue), or string (sValue).runtimeObjectholds extra data, including an editor location viaGetLocation/SetLocation. - Value types.
ValueTypeisBool,Integer,Float,String,Other,Array,Vector2,Vector3,MinMax2D,MinMax3D,Prefab, andNone. - Layers.
ILayeris aScriptableObject(a class, not an interface) that ownsList<Value> values, anenabledflag, and theGameObjectthe layer is bound to.findValuelooks a value up by name.getFloat,getInt,getBool, andgetStringreturn the stored field or a fallback when the name is missing. The matching setters write only when the name exists. - Triggers.
ILayer.setTriggersets a bool value to true for a given number of frames.updatecounts those frames down and clears the bool.RuntimeValueCollection.SetTriggerholds the bool true for three frames on a coroutine started on theMonoBehaviouryou pass in. - Conditions. A
Conditionasset points at aValue, anOperation(Is,IsNot,IsGreater,IsGreaterOrEqual,IsLess,IsLessOrEqual), a typed constant, and anextOperandofAndorOrfor the following condition. - Runtime copy.
RuntimeValueCollection.InitWithLayercopies a layer's values intoRuntimeValueDataentries, indexed by name and byname.GetHashCode(). It setstypeand copies the bool, integer, float, string, andOtherpayloads. OtherValueTypevalues are still created, with their type set and no payload copied.InitWithLayerAsynccopies those same payloads and yields once per value, and does not assigntype. Setters that take a name log a warning and return when the name is missing. Getters that take a name assert when it is missing. The hash overloads assert when the hash is missing.SetObject/GetObjectuse the untypedpValuefield.SetFloat,SetInt,SetBool,SetString, andSetObjectraiseValueChangedwith the value name.SetTriggerdoes not. - Condition checks.
RuntimeValueData.compareevaluates aRuntimeConditionDatafor bool, integer, float, string, andOther.Value.CompareandRuntimeValueData.comparealso compare two floats with anOperation. - External storage.
IValueStorageis the get/set surface (float, int, bool, string) used when another system saves or loads runtime values. - Runtime data attribute.
RuntimeDataAttributemarks a class with the runtime-data type to construct.createRuntimeDataFromAttributeinstantiates that type. - Enum lookup.
ValueEnumAttributetags an enum with a name.FindAttributeForPathsearches the executing assembly for a match. - Binary write.
Value.Write,Condition.Write, andILayer.Writewrite their fields with aBinaryWriter. There is no matching reader in this package. - Editor values.
ValueUtilscreates and removesValueandConditionsub-assets, clones a value list onto a parent asset, and imports or exports anILayer's bool, int, float, and string values as a NewtonsoftJArray.ValueGUIdraws layer values, runtime values, and a condition row. - Editor canvas.
GenericWindow<T>is anEditorWindowwith pan, zoom, selection, a grid background, and a properties pane.EditorBehaviourGUIsupplies the shared styles, node colors, icon lookup, and line, arrow, and bezier drawing used by the sibling editor windows.EditorIconscaches built-in editor icons.EditorZoomArea(namespaceVNKit) scales a GUI rect around a pivot.Lines/Colored Blendedis the line shader. - Inspector helpers.
SpreadAttributeplusSpreadDrawerdraws a float or int and, when the named delta field is non-zero, a ± field stored on that other serialized property.BTAnimatorParamAttributecarries aValueTypefor a property drawer defined in the behaviour-tree package.
Unity Package Manager, git URL:
https://github.com/denchi/UnityBehaviorVars.git
From the Package Manager window choose Add package from git URL and paste that URL, or add this to Packages/manifest.json:
{
"dependencies": {
"com.deathbygravitystudio.behaviour.vars": "https://github.com/denchi/UnityBehaviorVars.git"
}
}The package root is the repository root (package.json sits next to Runtime/ and Editor/).
Create a layer, add a float value, copy it into a runtime collection, then test it with a condition. This is the same path the HFSM, tree, and dialog packages use: asset values stay on the ILayer, and gameplay code reads and writes the RuntimeValueCollection.
using Behaviours;
using Behaviours.Runtime;
using UnityEngine;
public class HealthGate : MonoBehaviour
{
RuntimeValueCollection _values;
void Start()
{
var layer = ScriptableObject.CreateInstance<ILayer>();
var health = ScriptableObject.CreateInstance<Value>();
health.Name = "health";
health.type = ValueType.Float;
health.fValue = 100f;
layer.values.Add(health);
_values = new RuntimeValueCollection();
_values.InitWithLayer(layer);
_values.ValueChanged += OnValueChanged;
_values.SetFloat("health", 40f);
}
void OnValueChanged(string valueName)
{
if (valueName != "health")
return;
var health = _values.GetRuntimeValue("health");
var belowHalf = new RuntimeConditionData
{
value = health,
operation = Operation.IsLess,
fConstant = 50f
};
if (health.compare(belowHalf))
Debug.Log("health is below 50");
}
}InitWithLayer copies fValue (100). SetFloat writes the runtime copy and raises ValueChanged. compare then checks that runtime float against fConstant. The asset's Value.fValue is left at 100.
In editor code, ValueUtils.createValue(layer, "health", ValueType.Float) creates the Value and adds it to the layer asset. ValueGUI.DrawLayerValues draws the list.
Each package depends on com.deathbygravitystudio.behaviour.vars 0.1.0 and references the Behaviour.Vars assembly.
| Repository | Package | What it uses from this package |
|---|---|---|
| UnityBehaviorHFSM | com.deathbygravitystudio.behaviour.hfsm |
Layer extends ILayer. RuntimeLayerData calls RuntimeValueCollection.InitWithLayer. Transitions store Condition assets and evaluate them with RuntimeConditionData and RuntimeValueData.compare, combined with Operand. HFSMWindow extends GenericWindow<Node> and draws with EditorBehaviourGUI, EditorIcons, ValueGUI, and ValueUtils. Cloning a transition uses VarsUtils.Clone. Services use RuntimeDataAttribute. |
| UnityBehaviorTree | com.deathbygravitystudio.behaviour.tree |
Tree extends ILayer (CreateAssetMenu Behaviours/Tree). RuntimeTreeData.init calls InitWithLayer. The Behaviour runner forwards getFloat / setFloat (and int, bool, string, plus SetTrigger) to that collection, by name or by hash. BTWindow extends GenericWindow<Node> and uses EditorBehaviourGUI and ValueGUI.DrawLayerValues. Tasks and services use RuntimeDataAttribute. BTVarAttribute stores a ValueType. The tree package's property drawer targets BTAnimatorParamAttribute from this package. |
| UnityBehaviorGraph | com.deathbygravitystudio.behaviour.graph |
Graph extends ILayer (CreateAssetMenu Behaviours/Graph). Node inputs, outputs, and const/math tasks are tagged with ValueType. Runtime tasks carry RuntimeValueData, including ValueType.Array lists on pValue. createWithGraph copies graph.values into its own List<RuntimeValueData> instead of calling InitWithLayer. GraphWindow extends GenericWindow<Node>, draws with EditorBehaviourGUI, and calls ValueGUI.DrawLayerValues. |
| UnityBehaviorDialogs | com.deathbygravitystudio.behaviour.dialog |
Dialog extends ILayer. RuntimeDialog.CreateRuntimeDialog calls InitWithLayer. Option conditions are built with the HFSM helper Utils.CreateRuntimeCondition (the dialog package also depends on Behaviour HFSM) and combined with Operand in EvaluateConditions. DialogActionSet writes a runtime value with SetInt, SetFloat, SetBool, or SetString. SaveRuntimeValues / LoadRuntimeValues go through IValueStorage. The inspector draws vars with ValueGUI.DrawLayerValues. |
This repository does not declare a Unity version. package.json has no unity or unityRelease field, and there is no ProjectSettings/ProjectVersion.txt. The code uses ScriptableObject, EditorWindow, and assembly definitions without a version constraint.
The editor JSON import and export in ValueUtils references Newtonsoft.Json.Linq. package.json does not list that dependency.
MIT. Copyright (c) 2026 Denis Chiriac / Death By Gravity Studio.