armory/Sources/armory/logicnode/MaterialNode.hx

32 lines
582 B
Haxe
Raw Permalink Normal View History

2017-04-08 20:05:35 +02:00
package armory.logicnode;
2017-11-20 15:16:52 +01:00
import iron.data.MaterialData;
2017-04-08 20:05:35 +02:00
class MaterialNode extends LogicNode {
2019-12-19 23:54:08 +01:00
public var property0: String;
public var value: MaterialData = null;
2017-04-08 20:05:35 +02:00
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-08 20:05:35 +02:00
super(tree);
2017-11-20 15:16:52 +01:00
iron.Scene.active.notifyOnInit(function() {
2017-04-08 20:05:35 +02:00
get(0);
});
}
2019-12-19 23:54:08 +01:00
override function get(from: Int): Dynamic {
2018-04-21 06:23:31 +02:00
if (property0 != null) {
2019-12-19 23:54:08 +01:00
iron.data.Data.getMaterial(iron.Scene.active.raw.name, property0, function(mat: MaterialData) {
2018-04-21 06:23:31 +02:00
value = mat;
});
}
2017-04-08 20:05:35 +02:00
return value;
}
2019-12-19 23:54:08 +01:00
override function set(value: Dynamic) {
2017-04-08 20:05:35 +02:00
this.value = value;
}
}