با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این مبحث نحوه استفاده از دستاوردهای خدمات Play Games در بازیهای Unity را شرح میدهد. این فرض را بر این میگذارد که پروژه خود و افزونه Google Play Games را برای Unity راهاندازی کردهاید، همانطور که در راهنمای شروع کار توضیح داده شد.
یک دستاورد ایجاد کنید
هنگامی که پروژه و افزونه خود را راه اندازی می کنید، دستاوردها را در کنسول Google Play ایجاد کنید و سپس افزونه را با منابع Android برای دستاوردهای خود به روز کنید. برای جزئیات درباره ایجاد دستاوردها در Play Console، به راهنمای دستاوردها مراجعه کنید.
یک دستاورد را آشکار و باز کنید
برای باز کردن قفل یک دستاورد، از روش Social.ReportProgress با مقدار پیشرفت 100.0f استفاده کنید:
usingGooglePlayGames;usingUnityEngine.SocialPlatforms;...// unlock achievement (achievement ID "Cfjewijawiu_QA")Social.ReportProgress("Cfjewijawiu_QA",100.0f,(boolsuccess)=>{// handle success or failure});
با توجه به رفتار مورد انتظار Social.ReportProgress ، مقدار 0.0f به معنای آشکار شدن دستاورد و پیشرفت 100.0f به معنای باز شدن قفل دستاورد است.
برای آشکار کردن دستاوردی که قبلاً بدون باز کردن قفل آن پنهان شده بود، با Social.ReportProgress با مقدار 0.0f تماس بگیرید.
افزایش یک دستاورد
اگر دستاورد افزایشی باشد، اجرای بازیهای Play Social.ReportProgress سعی میکند مطابق با API اجتماعی Unity، رفتار مورد انتظار را رعایت کند. اگرچه ممکن است این رفتار یکسان نباشد، بنابراین توصیه می کنیم از Social.ReportProgress برای دستاوردهای افزایشی استفاده نکنید. در عوض، از روش PlayGamesPlatform.IncrementAchievement استفاده کنید، که یک برنامه افزودنی بازی های Play است.
usingGooglePlayGames;usingUnityEngine.SocialPlatforms;...// increment achievement (achievement ID "Cfjewijawiu_QA") by 5 stepsPlayGamesPlatform.Instance.IncrementAchievement("Cfjewijawiu_QA",5,(boolsuccess)=>{// handle success or failure});
نمایش رابط کاربری دستاوردها
برای نشان دادن رابط کاربری داخلی برای همه دستاوردها، با Social.ShowAchievementsUI تماس بگیرید.
usingGooglePlayGames;usingUnityEngine.SocialPlatforms;...// show achievements UISocial.ShowAchievementsUI();
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-07-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Achievements in Unity games\n\nThis topic describes how to use Play Games Services achievements in Unity\ngames. It assumes that you've set up your project and the\nGoogle Play Games plugin for Unity, as discussed in the\n[Get started guide](/games/pgs/unity/unity-start).\n\nCreate an achievement\n---------------------\n\nWhen you set up your project and plugin, create the achievements in\nGoogle Play Console and then update the plugin with the Android resources\nfor your achievements. For details about creating achievements in\nPlay Console, see the\n[achievements guide](/games/pgs/achievements#create_an_achievement).\n\nReveal and unlock an achievement\n--------------------------------\n\nTo unlock an achievement, use the **Social.ReportProgress** method with a\nprogress value of 100.0f: \n\n using GooglePlayGames;\n using UnityEngine.SocialPlatforms;\n ...\n // unlock achievement (achievement ID \"Cfjewijawiu_QA\")\n Social.ReportProgress(\"Cfjewijawiu_QA\", 100.0f, (bool success) =\u003e {\n // handle success or failure\n });\n\nAccording to the expected behavior of\n[Social.ReportProgress](http://docs.unity3d.com/Documentation/ScriptReference/Social.ReportProgress.html),\na value of 0.0f means the achievement is revealed and a progress of 100.0f\nmeans the achievement is unlocked.\n\nTo reveal an achievement that was\npreviously hidden without unlocking it, call **Social.ReportProgress** with\na value of 0.0f.\n\nIncrement an achievement\n------------------------\n\nIf the achievement is incremental, the Play Games implementation of\n**Social.ReportProgress** will try to adhere to the\nexpected behavior according to Unity's social API. The behavior might not be\nidentical, though, so we recommend that you don't use **Social.ReportProgress**\nfor incremental achievements. Instead, use the\n[PlayGamesPlatform.IncrementAchievement](/games/services/unity/v2/api/class/google-play-games/play-games-platform#incrementachievement) method, which is a\nPlay Games extension. \n\n using GooglePlayGames;\n using UnityEngine.SocialPlatforms;\n ...\n // increment achievement (achievement ID \"Cfjewijawiu_QA\") by 5 steps\n PlayGamesPlatform.Instance.IncrementAchievement(\n \"Cfjewijawiu_QA\", 5, (bool success) =\u003e {\n // handle success or failure\n });\n\nShow the achievements UI\n------------------------\n\nTo show the built-in UI for all achievements, call\n**Social.ShowAchievementsUI**. \n\n using GooglePlayGames;\n using UnityEngine.SocialPlatforms;\n ...\n // show achievements UI\n Social.ShowAchievementsUI();"]]