- Home /
OpenFeint Achievement Implementation
I implemented the openFeint plugin (from the openfeint website) and works like a charm. However, being new to this, I am pretty much clueless on how to actually add an actual achievement. I followed the guides from openfeint website but I am not sure I've done it right;
I made a new C# script named FeintAchievement and wrote this:
using UnityEngine; using System.Collections;
import com.openfeint.api.resource.Achievement; import android.widget.Toast; // Used for presenting diagnostic messages.
public class FeintAchievement : MonoBehaviour
new Achievement("941962").unlock(new Achievement.UnlockCB () { @Override public void onSuccess() { FeintAchievement.this.setResult(Activity.RESULT_OK); FeintAchievement.this.finish(); } @Override public void onFailure(String exceptionMessage) { Toast.makeText( FeintAchievement.this, "Error (" + exceptionMessage + ") unlocking achievement.", Toast.LENGTH_SHORT).show(); FeintAchievement.this.setResult(Activity.RESULT_CANCELED); FeintAchievement.this.finish(); } });
I have a number of errors here:
Assets/PiratesHat!/PiratesHatAssets/Scripts/FeintAchievement.cs(11,3): error CS1031: Type expected
Assets/PiratesHat!/PiratesHatAssets/Scripts/FeintAchievement.cs(12,23): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration
And it goes like this - the last error tells me I probably took the wrong route :)
Assets/PiratesHat!/PiratesHatAssets/Scripts/FeintAchievement.cs(21,2): error CS8025: Parsing error
I couldn't find a complete tutorial on this, I don't even know if achievements can be done via script or I should do something with the jar files and whatnot. I am totally lost here :)
So, be kind and guide me to a tutorial or documentation that deals with the matter.
Thanks! (a lot)
Answer by CallToAdventure · May 05, 2011 at 11:33 AM
It was actually easy. After a bit more digging, I found the solution:
using UnityEngine;
using System.Collections;
public class OFAchievement : MonoBehaviour {
private static OpenFeintFacade openFeint;
void Start(){
openFeint = new OpenFeintFacade();
openFeint.UnlockAchievement(941962);
}
}
Now, when the mission starts, the Achievement 941962 is unlocked.
Your answer
Follow this Question
Related Questions
Problem reading sensor plugin, event won't trigger 2 Answers
Build fails with Android plugin 0 Answers
Does anyone know a Screen recorder equivalent for android? 2 Answers
Launch of external activity from a unity freezes 0 Answers
Android Unity Plugin problem 0 Answers