PlayCanvasチートシート Unityと比べてみよう エディタ拡張編 その1

上位互換
seiroise.hatenablog.com

PlayCanvasのエディタ拡張的な要素である「スクリプト属性」について
あんまり日本語の解説がなかったのでUnityと比較してまとめてみる。

参考

pc.ScriptAttribute

Unity

public Color color;

PlayCanvas

Attribute.attributes.add("color", {
    type: "rgba"
});

こんな感じになる
f:id:seiroise:20170508181803p:plain
f:id:seiroise:20170508193922g:plain

スライダー

Unity

[Range(100f, 250f)]
public float height = 175.8f;

PlayCanvas

Test.attributes.add("height", {
    type: "number",
    placeholder: "cm",
    default: 175.8,
    min: 100,
    max: 250
});

こんな感じになる
f:id:seiroise:20170508194339g:plain

配列

Unity

public string[] characters;

PlayCanvas

Test.attributes.add("characters", {
    type: "string",
    array: true,
});

こんな感じになる
f:id:seiroise:20170508194848g:plain
ちなみに重複は許されない(gifだと"太郎"のところ)

列挙

Unity

public enum Value {
    valueOne = 1,
    valueTwo = 2,
    valueThree = 3
}

public Value value;

PlayCanvas

Test.attributes.add("value", {
    type: "number",
    enum: [
        {"valueOne": 1},
        {"valueTwo": 2},
        {"valueThree": 3}
    ]
});

こんな感じになる
f:id:seiroise:20170508195512g:plain

曲線

Unity

public AnimationCurve wave;

PlayCanvas

Attribute.attributes.add("wave", {
    type: "curve"
});

こんな感じになる
f:id:seiroise:20170508195950g:plain

備考

Unityにはない使い方ができるものもあるので、 それはまた今度