To update or not to update the doc ... That is the question :)

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;
  • Solution 2:
const myDiffuseTexture = new Texture(...);
myDiffuseTexture.uOffset = 1.5;
myMaterial.diffuseTexture = myDiffuseTexture;

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.

What do you think?


I love this feedback :slight_smile:

@PirateJC might provide guidance on this one.

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 :slight_smile:

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.

I’ll make this addition tomorrow.


Thanks both for the feedback!

@PirateJC if you have had a chance add the FYI let us know and I will mark the question as solved. (I couldn’t see one yet.)

Oh! Thanks so much for the follow up! I’ll tackle this right now!

Here we go. This will hopefully help those that are first coming to the docs, know that the examples used are intentionally in javascript.