Adventure Creator Wikia
Advertisement

Notes: this Action lets you unlock steam achievements in an actionlist.

using UnityEngine;
using System;
using System.Collections;
using Steamworks;

#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

[System.Serializable]
public class ActionUnlockAchievement : Action
{

// Declare variables here
public string AchievementID = "";

public ActionUnlockAchievement()
{
this.isDisplayed = true;
category = ActionCategory.Custom;
title = "Unlock Steam Achievement.";
description = "Unlocks an steam Achievement.";
}

override public float Run ()
{
//your action:
if (SteamManager.Initialized) 
{
if(AchievementID!=String.Empty)
{

try
{
SteamUserStats.SetAchievement(AchievementID);
SteamUserStats.StoreStats();
}
catch(Exception e)
{
Debug.LogError("Error while setting steam 

achievements...");
}

}
}
//end the action
return 0f;
}


#if UNITY_EDITOR

override public void ShowGUI ()
{
// Action-specific Inspector GUI code here
AchievementID = EditorGUILayout.TextField("Achievement ID: ", AchievementID , 

GUILayout.ExpandWidth(true));
AfterRunningOption ();
}


public override string SetLabel ()
{
// Return a string used to describe the specific action's job.
string labelAdd = "Unlocks an steam Achievement.";
return labelAdd;
}
#endif
}

}
Advertisement