Studio GuideWorld SDK Guide
Log In

User Information

Searching User Information

User information can be searched using the ZepetoWorldHelper.GetUserInfo function.
The callback function included in the UserID such as the time of completion, time of error occurrence, and string array is passed as an argument.


The following is an example of calling the ZepetoWorldHelper.GetUserInfo function.

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);
});

The following is a full example code for searching user information.
Please change "userId_1","userId_2" values to real userid values when using the example code.

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);
        });
    }
}
1183

Search User Information Run Screen


Importing User Profile Image

Use the ZepetoWorldHelper.GetProfileTexture function to load a user's profile photo.

The callback function from the time of completion to time of error occurrence and UserId is passed as an argument.


The following is an example code for calling the ZepetoWorldHelper.GetProfileTexture function.

ZepetoWorldHelper.GetProfileTexture(this.userId, (texture: Texture) => {
    this.sampleImage.sprite = this.GetSprite(texture);

}, (error) => {
    console.log(error);
});

The following is an example code that imports a user's profile photo.

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));
    }
}
1214

User Profile Image Run Screen