2
0
ShiroSmith 4 жил өмнө
parent
commit
6babf65f3c

+ 11 - 1
hide/comp/SceneEditor.hx

@@ -456,7 +456,7 @@ class SceneEditor {
 				value : o,
 				text : o.name,
 				icon : "fa fa-"+icon,
-				children : (o.children.length > 0 && !p.hideChildren) || (ref != null && @:privateAccess ref.editMode),
+				children : o.children.length > 0 || (ref != null && @:privateAccess ref.editMode),
 				state: state
 			};
 			return r;
@@ -491,6 +491,16 @@ class SceneEditor {
 		}
 		tree.get = function(o:PrefabElement) {
 			var objs = o == null ? sceneData.children : Lambda.array(o);
+			if( o != null && o.getHideProps().hideChildren != null ) {
+				var hideChildren = o.getHideProps().hideChildren;
+				var visibleObjs = [];
+				for( o in objs ) {
+					if( hideChildren(o) )
+						continue;
+					visibleObjs.push(o);
+				}
+				objs = visibleObjs;
+			}
 			var ref = o == null ? null : o.to(Reference);
 			@:privateAccess if( ref != null && ref.editMode && ref.ref != null ) {
 				for( c in ref.ref )

+ 1 - 1
hide/prefab/HideProps.hx

@@ -3,11 +3,11 @@ package hide.prefab;
 typedef HideProps = {
 	var icon : String;
 	var name : String;
-	@:optional var hideChildren : Bool;
 	@:optional var fileSource : Array<String>;
 	@:optional dynamic function allowChildren( type : String ) : Bool;
 	@:optional dynamic function allowParent( p : hrt.prefab.Prefab ) : Bool;
 	@:optional dynamic function onChildUpdate( p : hrt.prefab.Prefab ) : Void;
 	@:optional dynamic function onChildListChanged() : Void;
 	@:optional dynamic function onResourceRenamed( map : (oldPath : String) -> String ) : Void;
+	@:optional dynamic function hideChildren( p : hrt.prefab.Prefab ) : Bool;
 }

+ 8 - 2
hrt/prefab/l3d/MeshSpray.hx

@@ -201,7 +201,7 @@ class MeshSpray extends Object3D {
 	}
 
 	override function getHideProps() : HideProps {
-		return { icon : "paint-brush", name : "MeshSpray", hideChildren : true };
+		return { icon : "paint-brush", name : "MeshSpray", hideChildren : p -> return Std.is(p, Model) };
 	}
 
 	function extractMeshName( path : String ) : String {
@@ -534,7 +534,13 @@ class MeshSpray extends Object3D {
 		});
 		options.find("#clean").click(function(_) {
 			if (hide.Ide.inst.confirm("Are you sure to remove all meshes for this MeshSpray ?")) {
-				sceneEditor.deleteElements(children.copy());
+				var meshes = [];
+				for( c in children ) {
+					if( Std.is(c, Model) ) {
+						meshes.push(c);
+					}
+				}
+				sceneEditor.deleteElements(meshes);
 				sceneEditor.selectObjects([this], Nothing);
 			}
 		});