あなたの世界を作りなさい
ソーシャル
ユーザー情報
4分
ユーザー情報の検索 zepetoworldhelper getuserinfo関数を使用してユーザー情報を検索できます。 useridに含まれるコールバック関数は、完了時刻、エラー発生時刻、文字列配列などが引数として渡されます。 以下は、zepetoworldhelper getuserinfo関数を呼び出す例です。 zepetoworldhelper getuserinfo(ids, (info users\[]) => { for (let i = 0; i < info length; i++) { console log(`userid ${info\[i] useroid}, name ${info\[i] name}, zepetoid ${info\[i] zepetoid}`); } }, (error) => { console log(error); }); 以下は、ユーザー情報を検索するための完全な例コードです。 例のコードを使用する際は、「userid 1」、「userid 2」の値を実際のユーザーidの値に変更してください。 import { zepetoscriptbehaviour } from 'zepeto script'; import { zepetoworldhelper, users } from 'zepeto world'; export default class userinfo extends zepetoscriptbehaviour { start() { let ids string\[] = \["userid 1", "userid 2"]; zepetoworldhelper getuserinfo(ids, (info users\[]) => { for (let i = 0; i < info length; i++) { console log(`userid ${info\[i] useroid}, name ${info\[i] name}, zepetoid ${info\[i] zepetoid}`); } }, (error) => { console log(error); }); } } ユーザープロフィール画像のインポート zepetoworldhelper getprofiletexture関数を使用して、ユーザーのプロフィール写真を読み込みます。 完了時からエラー発生時までのコールバック関数とuseridが引数として渡されます。 以下は、zepetoworldhelper getprofiletexture関数を呼び出すためのサンプルコードです。 zepetoworldhelper getprofiletexture(this userid, (texture texture) => { this sampleimage sprite = this getsprite(texture); }, (error) => { console log(error); }); 以下は、ユーザーのプロフィール写真をインポートするためのサンプルコードです。 import { zepetoscriptbehaviour } from 'zepeto script'; import { zepetoworldhelper } from 'zepeto world'; import { texture,texture2d, sprite, rect, vector2 } from 'unityengine'; import { image } from 'unityengine ui'; export default class gettextureexample extends zepetoscriptbehaviour { public userid string; public sampleimage image; start() { zepetoworldhelper getprofiletexture(this userid, (texture texture) => { this sampleimage sprite = this getsprite(texture); }, (error) => { console log(error); }); } getsprite(texture texture) { let rect rect = new rect(0, 0, texture width, texture height); return sprite create(texture as texture2d, rect, new vector2(0 5, 0 5)); } }