Only allow valid types in Decal, Light3D projector, PointLight2D texture and CSGMesh3D mesh

If an invalid type is supplied (which can still be done from a script),
a warning is printed (along with a workaround for ViewportTexture).

This also adds support for "negative" resource hints such as
"Texture2D,-ViewportTexture" to exclude one or more subclasses
from a class hint.

Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
This commit is contained in:
Hugo Locurcio
2024-02-15 00:26:37 +01:00
committed by Rémi Verschelde
parent 2b7ea6223b
commit 7a04d85ec3
10 changed files with 97 additions and 21 deletions

View File

@@ -1207,7 +1207,8 @@ void CSGMesh3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_material", "material"), &CSGMesh3D::set_material);
ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh3D::get_material);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
// Hide PrimitiveMeshes that are always non-manifold and therefore can't be used as CSG meshes.
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh,-PlaneMesh,-PointMesh,-QuadMesh,-RibbonTrailMesh"), "set_mesh", "get_mesh");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial"), "set_material", "get_material");
}