Being quite new to TypeScript, I just ran into this issue:
The doc suggests that a diffuse texture’s offset can be modified like this: myMaterial.diffuseTexture.uOffset = 1.5;
That works fine in JavaScript. TypeScript however, won’t let you do that, as the diffuseTexture property is of type BaseTexture, which doesn’t have a uOffset property.
Solution 1:
(myMaterial.diffuseTexture.uOffset as Texture).uOffset = 1.5;
As there are a few forum questions regarding just this, I was considering adding a small comment to the doc. But maybe I just hit the tip of the iceberg and there are 100’s of similar examples scattered through the doc? In that case a general warning for TypeScript users early in the doc might be more effective.
There are probably plenty of code like this throughout the doc as the samples are mostly JS based. I would think a Typescript general warning would do but I am also fully biased
Maybe junior members of the community could decide what would be best for them ?
Yeah I think you’re both right. Given that our documentation is largely geared towards javascript examples, there are probably hundreds or even thousands of alternative typescript examples we could give as well. This would probably a be fairly daunting effort, but might also be useful folks.
Something nice that Unity used to do in the past is allowing users to select their language of choice and then the documentation would update with examples for the chosen language. Again, probably a pretty daunting project that we’d DEFINITELY need community contribution to help pull of, but could also be an interesting idea for the future.
For now I think a general “FYI” in the very beginning of the doc that these docs mainly use javascript examples will probably be the safest bet.