So I am currently trying to create a plane that will create GUI buttons on any screens that I selected as designated mesh.
I understand that you can assign the plane’s parent into the selected mesh but will it be possible to size it as well the same of the parent/selected mesh.
In the GUI Editor, we take a 1,1 plane and then render a advanceTexture onto the mesh.
We do this with:
adt = AdvancedDynamicTexture.CreateForMesh(textureMesh, textureSize, textureSize, true);
Now the next thing we do is scale up the planes size to match the adt.
textureMesh.scaling.x = textureSize;
textureMesh.scaling.y = textureSize;.
You can then update the size of the adt or the plane when you need to. For example if you are switching meshes. Here is how it’s done in the editor:
textureMesh.scaling.x = newvalue.x;
textureMesh.scaling.y = newvalue.y;
adt.scaleTo(newvalue.x, newvalue.y);
adt.markAsDirty();
Hope this helps and please let me know if you have follow up questions.
Hi @msDestiny14 ! Thank you for your input. I am currently trying to apply the solution you mentioned. Just a quick question is the textureSize refer to the:
Texture size is a predefined value, whatever you want to make it. It could be the size of all your different screens that you have.
Oh yes, the scaling would be Y. (It’s Z on the editor because of the angle of the camera so sorry for the confusion. Let me edit the code the be generalized)
Sorry just to clarify. Is the textureSize something I can get on the Mesh class (Since scene.getMeshById returns that type) and if so what property/function would it be?.
But what if you were not the one who made the mesh but rather simply load it?
So in this case I’m essentially just loading a mesh and only has the name of the mesh I want to apply a screen at.
Will there be a way to compute the textureSize? (Sorry for asking a lot >.<)
So you can information about the mesh to determine the right size you’ll need.
Also if you are just switching the texture to be on the different sized meshes then it should be calculating this automatically when you call AdvancedDynamicTexture.CreateForMesh(mesh) width and height specifications are optional.
Got it that should complete it! I guess last question for me (though it may be out of topic for this thread). So when I try to apply that plane to the parent mesh. It seems that it is inside of the mesh (see image for reference)