LoginSignup
0
0

More than 1 year has passed since last update.

PlayCanvasのコードエディターでコード補完をする

Last updated at Posted at 2022-09-20

PlayCanvas標準のコードエディタを利用している場合にコード補完が効かない場合があります。その場合にはJSDocのアノテーションを追加することで標準のエディターでコード補完ができます。

var Exmaple = pc.createScript('example');

Example.prototype.initialize = function() {
  // ① ※ pc.GraphNodeとされるためEntityのコード補完が効かない
  const cube = this.app.root.findByName("Root");
  cube.rotateLocal(0, 0.1, 0);

  // ② ※ pc.Entityとして扱われる
  /** @type {pc.Entity} */
  const typedCube = this.app.root.findByName("Root");
  typedCube.rotateLocal(0, 0.1, 0);
}

① / ②それぞれの違いについて

① ※ pc.GraphNodeとされるためEntityのコード補完が効かない
スクリーンショット 2022-08-22 13.50.28.png

② ※ pc.Entityとして扱われる
スクリーンショット 2022-08-22 13.50.03.png

参考

変数以外にも関数などについても同様に補完ができます。記述方法などについてはこちらが参考になります。

PlayCanvasのコンポーネント名などについてはこちらが参考になります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0