Armory Basics. Traits

Traits , as you might have guessed from previous posts, is the scripting system in Armory. If you worked with the Source engine, then you probably remember these pink cubes - there they were called Entities. So it is with us, the essence is the same. In our case, the traits used can only be viewed in the Outliner by switching to the Orphan Data view in Collections . This is extremely inconvenient because there is no visual display in scripts in the scene.





Traits types





Traits :





  • Haxe - Haxe.





  • Wasm - . WebAssembly.





  • UI - .





  • Bundled - / Haxe.





  • Nodes - Logic Editor ( blueprints UE4).





(!) .





Fake User





Logic Editor traits - . , Blender     . trait . , .





Traits Events

Trait :





  • Trait.notifyOnAdd() - trait.





  • Trait.notifyOnInit() - .





  • Trait.notifyOnRemove() - .





  • Trait.notifyOnUpdate() - .





  • Trait.notifyOnRender() - .





  • Trait.notifyOnRender2D() - 2D.





. , onInit . trait , Scene.active.notifyOnInit() - .





traits

Blender. @prop. var . Final , trait Haxe Reflection API, .









  • :





    • Int





    • Float





    • Boolean





  • String









    • iron.object.Object





    • iron.object.CameraObject





    • iron.object.LightObject





    • iron.object.MeshObject





    • iron.object.SpeakerObject





  • :





    • iron.math.Vec2





    • iron.math.Vec3





    • iron.math.Vec4





:





 package arm;
 
 // See below ("Object data types")
import iron.object.CameraObject;
 
import iron.math.Vec2;
import iron.math.Vec3;
import iron.math.Vec4;
 
class MyTrait extends iron.Trait {
	// Primitive data types
	@prop
	var intValue: Int = 40; // Type annotation possible, but not required
	@prop
	var floatValue = 3.14;
	@prop
	var stringValue = "Hello world!";
	@prop
	var booleanValue = true;
 
	// Object data types
	@prop
	var objValue: iron.object.Object; // Needs type annotation to be recognized
	@prop
	var camObjValue: CameraObject; // Type can be imported (see above)...
	@prop
	var lightObjValue: iron.object.LightObject; // .. or not, both will work
	@prop
	var meshObjValue: iron.object.MeshObject;
	@prop
	var speakerObjValue: iron.object.SpeakerObject;
 
	// Vector data types
	@prop
	var vector2DValue: Vec2 = new Vec2(0.2, 0.5); // Initialization possible...
	@prop
	var vector3DValue: Vec3; //... but not required
	@prop
	var vector4DValue = new Vec4(1, 2, 3, 4);
 
	// Not visible in Blender, `@prop` is missing
	var notVisibleValue = 0.0;
 
	// ...
}
      
      







:





@prop:





  • @prop  





  •  









  • , , .





traits sources/ arm. - , - . .





, Haxe package syntax traits. trait general.BoxBehavior - Sources/arm/general «BoxBehavior.hx»





, traits :  «general.terrain.TerrainCollider» «TerrainCollider.hx» «Sources/arm/ general/terrain».





, Class .





  1. Armory Engine.





  2. Armory





  3. Wasm in the Armory Engine












All Articles