Google Cloud Print Plugin for Unity
Information Documentation Support Type : Unity 3D Plugin The first plugin to use the Google Cloud Print services in Unity projects. Comming soon on the Unity Asset Store How to use Google Cloud Print Plugin 1. Init a new scene When the unity package is installed on your project, create a new scene. In this scene create a new empty object named “Main” (for example) and attach to him the “Google Authentication” and the “Google Cloud Print Plugin” Components. 2. Create your script Create a new script named “GoogleCloudPrintTest” (for example) and attach it to your “Main” game object too. Create some variables and on the “Start” method retrieve your components. private static string APP_PROXY = "com.myproject"; private GoogleCloudPrintPlugin GCPPlugin; private GoogleAuthentication googleAuthentication; void Start () { // Retrieve plugin component googleAuthentication = GetComponent(); GCPPlugin = GetComponent(); // Init plugin GCPPlugin.AppProxy = APP_PROXY; } Now you are ready to call the Google Cloud Print services ! 3. Connect a user There is several methods to connect a user with the Google services. The plugin provide you 3 methods. The Client Login method The OAuth2 method The GetAuthTokenByFeatures method for the Android devices Connect a user with the Client Login method (more informations at https://developers.google.com/accounts/docs/AuthForInstalledApps) Just call the “ClientLogin” method on the “GoogleAuthentication” classe with a google login and password. googleAuthentication.ClientLogin("HOSTED_OR_GOOGLE", "yourGmailEmail", "yourGmailPassword", "cloudprint", APP_PROXY, (success, message, SID, LSID, auth) => { if (success) { // For example, store the client auth string clientId = auth; // Do something... // Update authorization type GCPPlugin.AuthorizationType = GoogleCloudPrintPlugin.GCPAuthorizationType.GoogleLogin; } else { // For example, store the error message string errorMessage = message; // Do something... } }); Connect a user with the OAuth2 method (more informations at https://developers.google.com/accounts/docs/OAuth2) Just call the “OAuth2Code” and “OAuth2Token” methods on the “GoogleAuthentication” classe. private static string AppClientId = "yourAppClientId"; private static string AppClientSecret = "yourAppClientSecret"; private static string REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"; // urn:ietf:wg:oauth:2.0:oob for a mobile app or another url set in your application private static string SCOPE = "https://www.googleapis.com/auth/cloudprint"; // ... // Open a browser and get a code for the user googleAuthentication.OAuth2Code("code", AppClientId, REDIRECT_URI, SCOPE); // .. When the user have accepted the app and have the code you can call the other method to get a token. // ... // Retrieve an OAUth2 Token googleAuthentication.OAuth2Token(authCode, AppClientId, AppClientSecret, REDIRECT_URI, "authorization_code", SCOPE, (success, message, accessToken, tokenType, expiresIn, refreshToken) => { if (success) { // Store the auth token string authToken = accessToken; // Do something... // Update authorization type GCPPlugin.AuthorizationType...
2d Toolkit UI Playmaker Actions
Information Documentation Support Type : Unity 3D Plugin New Actions for Playmaker, centered around 2dtoolkit UI. These scripts provide Playmaker Action functionality for handling UI Item events. The Playmaker and 2dtoolkit UI plugins are needed. Download on the Unity Asset Store Script reference is available here How to use 2dtoolkit UI Playmaker Actions 1. Init the scene Create a new 2dToolkit Camera and a new tk2dUIManager game object with the “tk2dUIManager” component linked int your scene to use the 2dToolkit UI plugin. 2. Create a new UI Item You can use the control prefabs available in the tk2dUI_demo folder of 2D Toolkit. For example we can create a new Basic Button. 3. Use PlayMaker with the UI Item Open PlayMaker and add an FSM to the button or create a new game object and attach an FSM to him. 4. Discover the new 2dtoolkit UI Actions Click on state and click on the “Action Browser” button to add a new playmaker action. In the list of actions you can see the “2D Toolkit UI/UIITem” category . Click on this category and the actions appears : Get Click : Manage the click event in the UIITem Get Down : Manage the down event in the UIITem Get Hover : Manage the hover event in the UIITem Get Hover Out : Manage the hover out event in the UIITem Get Hover Over : Manage the hover over event in the UIITem Get Relase : Manage the release event in the UIITem Get Up : Manage the up event in the UIITem There is 2 version for each event. One basic version and one advanced version wich return the Game Object and the UIItem object associated with the UIItem. More informations about events are available in the official documentation of 2dtoolkit (http://www.unikronsoftware.com/2dtoolkit/docs/latest/html/classtk2d_u_i_item.html). 5. Use the new 2dtoolkit UI Actions All the actions have the same behaviour. For example we can use the click event. Just double click on it to add the actions in the FSM. There is 2 variables on the basic action : Game Object It’s the game object to use. If you have added the FSM directly on the UIITem Button you can select Use Owner else you can select another Game Object that contains a UIItem component. Send Event The event sent when the event is triggered. In this case the click event. And 2 more variables on the advanced action : Store UIIten Result Get the UIItem associated with this action Store Game Object Result Get the Game Object associated to the UIItem To use the action just create a...