Adventure Creator Wikia
Register
(Added a curly bracket)
Tags: Visual edit apiedit
(Formatting)
Tag: Visual edit
 
Line 1: Line 1:
 
Notes: this Action lets you unlock steam achievements in an actionlist. It requires the steamworks plugin instaleld on the project.
 
Notes: this Action lets you unlock steam achievements in an actionlist. It requires the steamworks plugin instaleld on the project.
   
To use it replace the text in a .cs file named ActionUnlockAchievement with this text, or create a new blank text file, then paste the text and rename the file ActionUnlockAchievement.cs. Then drop the file into the folder named actions inside the Adventure creator folder (or define your own folder in the Actions manager). Then, just use the action in an action list (from the custom category).
+
To use it replace the text in a .cs file named ActionUnlockAchievement with this text, or create a new blank text file, then paste the text and rename the file ActionUnlockAchievement.cs. Then drop the file into the folder named actions inside the Adventure creator folder (or define your own folder in the Actions manager). Then, just use the action in an action list (from the custom category).<syntaxhighlight lang="csharp">
using UnityEngine;
+
using UnityEngine;
using System;
+
using System;
using Steamworks;
+
using Steamworks;
 
<nowiki>#</nowiki>if UNITY_EDITOR
 
using UnityEditor;
 
<nowiki>#endif
 
/* By Alvaro Urrutia Luna (Alverik)
 
</nowiki>* Custom action to
 
<nowiki> </nowiki>* Unlock Steam achievements.
 
<nowiki> */
 
namespace AC
 
{
 
 
[System.Serializable]
 
public class ActionUnlockAchievement : Action
 
{
 
 
// Declare variables here
 
public string AchievementID = "";
 
 
</nowiki> public ActionUnlockAchievement()
 
{
 
this.isDisplayed = true;
 
category = ActionCategory.Custom;
 
title = "Unlock Steam Achievement.";
 
description = "Unlocks an steam Achievement.";
 
}
 
 
override public float Run ()
 
{
 
<nowiki> </nowiki> //your action:
 
<nowiki> </nowiki> if (SteamManager.Initialized)
 
{
 
if(AchievementID!=String.Empty || AchievementID!="")
 
{
 
 
try
 
{
 
SteamUserStats.SetAchievement(AchievementID);
 
SteamUserStats.StoreStats();
 
}
 
catch(Exception e)
 
{
 
Debug.LogError("Error while setting steam achievements... " + e);
 
}
 
 
}
 
}
 
<nowiki> </nowiki> //end the action
 
<nowiki> </nowiki> return 0f;
 
<nowiki> }
 
 
 
#</nowiki>if UNITY_EDITOR
 
 
override public void ShowGUI ()
 
{
 
<nowiki> </nowiki> // Action-specific Inspector GUI code here
 
AchievementID = EditorGUILayout.TextField("Achievement ID: ", AchievementID , GUILayout.ExpandWidth(true));
 
<nowiki> </nowiki> 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
 
<nowiki>}}</nowiki>
 
   
 
#if UNITY_EDITOR
 
using UnityEditor;
  +
#endif
 
/* By Alvaro Urrutia Luna (Alverik)
 
* Custom action to
 
* Unlock Steam achievements.
  +
*/
 
namespace AC
  +
{
   
 
[System.Serializable]
 
public class ActionUnlockAchievement : Action
 
{
  +
 
public string AchievementID = "";
  +
  +
public override ActionCategory Category { get { return ActionCategory.Custom; }}
  +
public override string Title { get { return "Unlock Steam Achievement."; }}
 
public override string Description { get { return "Unlocks an steam Achievement."; }}
  +
 
override public float Run ()
 
{
  +
//your action:
 
if (SteamManager.Initialized)
 
{
 
if(AchievementID!=String.Empty || AchievementID!="")
 
{
 
try
 
{
 
SteamUserStats.SetAchievement(AchievementID);
 
SteamUserStats.StoreStats();
 
}
 
catch(Exception e)
 
{
 
Debug.LogError("Error while setting steam achievements... " + e);
 
}
  +
 
}
 
}
  +
//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));
 
}
  +
  +
 
public override string SetLabel ()
 
{
 
// Return a string used to describe the specific action's job.
 
string labelAdd = "Unlocks an steam Achievement.";
 
return labelAdd;
 
}
  +
 
#endif
  +
 
}
  +
  +
}
  +
</syntaxhighlight>
 
[[Category:Integrations]]
 
[[Category:Integrations]]

Latest revision as of 07:22, 3 June 2021

Notes: this Action lets you unlock steam achievements in an actionlist. It requires the steamworks plugin instaleld on the project.

To use it replace the text in a .cs file named ActionUnlockAchievement with this text, or create a new blank text file, then paste the text and rename the file ActionUnlockAchievement.cs. Then drop the file into the folder named actions inside the Adventure creator folder (or define your own folder in the Actions manager). Then, just use the action in an action list (from the custom category).

using UnityEngine;
using System;
using Steamworks;

#if UNITY_EDITOR
using UnityEditor;
#endif
/* By Alvaro Urrutia Luna (Alverik)
* Custom action to
* Unlock Steam achievements.
*/
namespace AC
{

	[System.Serializable]
	public class ActionUnlockAchievement : Action
	{

		public string AchievementID  = "";

		public override ActionCategory Category { get { return ActionCategory.Custom; }}
		public override string Title { get { return "Unlock Steam Achievement."; }}
		public override string Description { get { return "Unlocks an steam Achievement."; }}

		override public float Run ()
		{
			//your action:
			if (SteamManager.Initialized) 
			{
				if(AchievementID!=String.Empty || AchievementID!="")
				{
					try
					{
						SteamUserStats.SetAchievement(AchievementID);
						SteamUserStats.StoreStats();
					}
					catch(Exception e)
					{
						Debug.LogError("Error while setting steam achievements... " + e);
					}

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


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

		#endif

	}

}