สร้างโลกของคุณเอง
โซเชียล
ข้อมูลผู้ใช้
4นาที
ค้นหาข้อมูลผู้ใช้ สามารถค้นหาข้อมูลผู้ใช้ได้โดยใช้ฟังก์ชัน zepetoworldhelper getuserinfo ฟังก์ชัน callback ที่รวมอยู่ใน 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" เป็นค่าจริงของ userid เมื่อใช้โค้ดตัวอย่าง 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 เพื่อโหลดรูปโปรไฟล์ของผู้ใช้ ฟังก์ชัน callback จากเวลาที่เสร็จสิ้นไปจนถึงเวลาที่เกิดข้อผิดพลาดและ 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)); } }