Any examples out there on how I can change the design time values during run-time for the Mesh components (mesh details) attached to a game object. This toolkit seems to be promising but doesn’t have any examples or documentation. I just need to make a simple mesh object which was set visible during design phase (mesh details component) to invisible during run time after 30 seconds. Any simple examples please ?
//GetMesh.cs [BabylonProperty] public GameObject UnityComponentPropertyName; //GetMesh.ts //Get the unity component in this case it's a GO that I defined in the CS var myMesh: BABYLON.AbstractMesh = this.getProperty("UnityComponentPropertyName", null); //You have to get the mesh by a reference const meshid : string = myMesh.id; //use the scene to get the mesh by ID let sceneMesh = this.scene.getMeshByID(meshid); //Do logic to sceneMesh
Unfortunately I am not a programmer but an artist trying to play with Babylon js together with unity.
I am looking more for a complete but simple example just to understand how unity components (babylon exporter) are used in babylon at runtime. Like for example enabling and disabling an object at runtime.
I don’t fully understand what you’re expecting, since the only way to disable a Game object in runtime in Unity is:
myGameObject.enabled = false; you need to use code to do it, just like you’ll need to use code in babylon to do it.
The code that I gave you will disable an object in the babylon game scene at runtime. What confuses me is you’re looking for a complete but simple example, but that’s as complete and simple as it gets.
You use the Unity inspector to attach a Gameobject to your property, then at runtime Babylon will grab that component, then the mesh, then disable it. That’s what the
GetMesh.ts is doing.
Unity components (class objects) are just data that contain gameobject information (transforms, colliders, materials, etc) that is transfered over to babylon in a different way.
What are you stuck on, maybe we can figure it out together.
sorry for my ignorance. So if I understood correctly let’s say I have a cube (gameobject named cube) I will attach the babylon component (mesh details) to it first and then attach in addition to that your script ?? forgive me for the stupid question but does unity support Typescript (GetMesh.ts) ?
On your cube you will attach a mesh component (This will allow you to access the component in your typescript):
Then you will want to create a Unity specific component that you can attach to your cube:
Name both files
Attach the Editor script component to your Game object cube:
Now you are referencing that component to your
Cube.ts component, from there you can use my code in y our
Cube.ts and it will “act” almost the same as if it was a C# component, using the Typescript language. You don’t have access to the Unity API components but specific Babylon API components.
Think of the
Cube.ts as references, the .cs file “passes” the data of that object to the .ts through it’s constructor:
So you could do something like
this.name and it would output the cube gameobject name.
Thank you very much @i73 !!!
This was the information I was looking for.
Yep… @i73 is right.
There is a getting started video in documentation that uses typescript component to spin a cube