### Example manifest.json entry for Manual Installation Source: https://docs.lunalabs.io/docs/playable/setup/install-plugin Illustrates the correct relative path format for the 'uk.lunalabs.luna' entry in manifest.json, based on project and plugin folder locations. ```json "uk.lunalabs.luna": "file:../../Luna/scripts" ``` -------------------------------- ### Install Full Game with Luna.Unity.Playable.InstallFullGame Source: https://docs.lunalabs.io/docs/playable/javascript-playables/js-sdk Execute Luna.Unity.Playable.InstallFullGame() at the end of the gameplay cycle to initiate the full game installation. ```javascript Luna.Unity.Playable.InstallFullGame(); ``` -------------------------------- ### Install .NET SDK via Homebrew on Mac Source: https://docs.lunalabs.io/docs/playable/setup/dependencies Use this command to install the .NET SDK and targeting pack if you encounter issues with .NET installation on macOS. ```bash brew install --cask dotnet-sdk ``` -------------------------------- ### Manual Newtonsoft.Json DLL Installation Source: https://docs.lunalabs.io/docs/playable/code/json-in-plugin This snippet shows the manual installation process by placing the Newtonsoft.Json.dll file into the 'Plugins' folder within your Unity project's Assets directory. ```csharp using Newtonsoft.Json; // ... rest of your script ``` -------------------------------- ### Example: Configuring Various Game Variables and Assets Source: https://docs.lunalabs.io/docs/playable/playable-setup/configure-game-variables This example demonstrates how to apply `LunaPlaygroundField` and `LunaPlaygroundAsset` attributes to different serializable fields (Color, float, int, Texture, VideoClip) to make them configurable in the Unity Playworks editor, organized into 'Player Controls' and 'End Card' groups. ```csharp [Header("Playable Ad Settings")] [SerializeField] [LunaPlaygroundField("Color of the player", 1, "Player Controls")] private Color playerColor = Color.blue; [SerializeField] [LunaPlaygroundField("Speed of the player", 2, "Player Controls")] private float playerSpeed = 1f; [SerializeField] [LunaPlaygroundField("Number of levels", 3, "Game Controls")] private int gameLevels = 1; [SerializeField] [LunaPlaygroundField("Relative game difficulty", 4, "Game Controls")] private int gameDifficulty = 3; [SerializeField] [LunaPlaygroundAsset("Game Icon", 5, "End Card")] private Texture gameIconTexture; [SerializeField] [LunaPlaygroundAsset("Video Clip", 6, "End Card")] private VideoClip videoClip; ``` -------------------------------- ### Install Mono Framework via Homebrew on Mac Source: https://docs.lunalabs.io/docs/playable/setup/dependencies Install the Mono framework, which includes the MSBuild tool, using Homebrew on macOS. ```bash brew install --cask mono-mdk ``` -------------------------------- ### Example AppsFlyer Click Tracking URL Source: https://docs.lunalabs.io/docs/playable/attribution/appsflyer An example of a complete click tracking URL with the `af_addpb=1` parameter and other essential tracking parameters for AppsFlyer integration. ```text https://app.appsflyer.com/id1234567890?af_siteid={ApplicationId}_{ApplicationName}&c={CampaignName}&af_adset={adgroup_name}&af_ad={CreativeName}&clickid={DynamicParameter}&af_addpb=1 ``` -------------------------------- ### Pattern Matching Example Source: https://docs.lunalabs.io/docs/playable/code/plugin-compiler-v2 Demonstrates the use of pattern matching with 'is' and 'as' operators for type checking and casting. ```csharp if(fruit is Apple) { MakeApplePieFrom(fruit as Apple); } ``` -------------------------------- ### Implement Global startGame Function Source: https://docs.lunalabs.io/docs/playable/javascript-playables/js-sdk Ensure a global start game function is defined in your game for initialization. ```javascript window.startGame = () => { // your game initialization here }; ``` -------------------------------- ### Listen for Luna Build Event Source: https://docs.lunalabs.io/docs/playable/javascript-playables/setup Subscribes to the 'luna:build' event and logs a message when the playable is about to start. ```javascript // Subscribe to luna:build event – will be fired right after 'load' event of the window. window.addEventListener('luna:build', function () { log('Playable is about to start'); }); ``` -------------------------------- ### Applovin Challenge Events API Example Source: https://docs.lunalabs.io/docs/playable/ad-networks/applovin Log Applovin-specific challenge events using the Luna.Unity.Analytics API. Call these methods at appropriate points in your playable, such as when a user starts, fails, retries, or reaches a completion threshold in a challenge. ```csharp using Luna.Unity.Analytics; void OnChallengeStart() { Applovin.LogChallengeStarted(); } void OnChallengeProgress(float progress) { if (progress >= 0.25f) Applovin.LogChallengePass25(); if (progress >= 0.50f) Applovin.LogChallengePass50(); if (progress >= 0.75f) Applovin.LogChallengePass75(); } void OnChallengeComplete() { Applovin.LogChallengeSolved(); } ``` -------------------------------- ### Correct API Call for Installing Full Game Source: https://docs.lunalabs.io/docs/playable/code/error-codes/LP3014 This is the recommended API call to replace `Application.OpenURL()` when dealing with ad networks that require specific APIs. Use this to ensure proper functionality and avoid ad blocking. ```csharp Luna.Unity.Playable.InstallFullGame() ``` -------------------------------- ### Implement InstallFullGame API Call Source: https://docs.lunalabs.io/docs/playable/code/error-codes/LP3006 Call this API to prompt the user to install the full game, a requirement for certain ad networks. This helps in meeting ad network specifications. ```csharp Luna.Unity.Playable.InstallFullGame(); ``` -------------------------------- ### Deploy Project with Credentials (Mac) Source: https://docs.lunalabs.io/docs/playable/command-line Deploy the project and upload it to Unity Playworks by providing user email and token as parameters. ```bash ./jake project:deploy USER_EMAIL=your.email@domain.com USER_TOKEN=%yourToken% TARGET_PLATFORM=playground ``` -------------------------------- ### Navigate to PNGQuant Subdirectory Source: https://docs.lunalabs.io/docs/playable/setup/export-failures If the initial permission grant fails, navigate into specific subdirectories (e.g., mac64 or win64) within the tools directory and reapply permissions. ```bash cd pngquant ``` ```bash cd mac64 ``` ```bash cd win64 ``` -------------------------------- ### External JavaScript Library Example Source: https://docs.lunalabs.io/docs/playable/code/external-js-libraries This is an example of an external JavaScript library that can be linked to the Unity Playworks Plugin. Ensure the JS type is globally visible. ```javascript pc.MyTextListener = function () { this.stringProp = ''; this.enterKey = function (ctx) { console.log(this.stringProp + ' ' + ctx); }; }; ``` -------------------------------- ### Unity Playworks Fields Example Source: https://docs.lunalabs.io/docs/playable/javascript-playables/setup This example demonstrates how to populate the 'fields' object for Unity Playworks, showcasing different data types like color, enum, boolean, int32, vector3, string, and arrays, along with their default values and constraints. ```json "fields": { "ShapeController": { "shapeColor": { "title": "shapeColor", "type": "color", "defaultValue": [ 1, 0, 0, 1 ], "section": "", "order": 1, "localization": 0, "options": {} }, "shape": { "title": "shape", "type": "enum", "defaultValue": 1, "section": "", "order": 2, "localization": 0, "options": { "0": "CUBE", "1": "SPHERE", "2": "CYLINDER" } }, "someBoolean": { "title": "someBoolean", "type": "boolean", "defaultValue": 1, "section": "", "order": 3, "localization": 0, "options": {} }, "someInt": { "title": "someInt", "type": "int32", "defaultValue": 100, "section": "", "order": 4, "localization": 0, "options": {} }, "someVector3": { "title": "someVector3", "type": "vector3", "defaultValue": [ 0, 1, 0 ], "section": "", "order": 5, "localization": 0, "options": {} }, "someString": { "title": "someString", "type": "string", "defaultValue": [ "This is a string" ], "section": "", "order": 6, "localization": 0, "options": {} }, "mySlider":{ "title": "mySlider", "type": "int32", "defaultValue": 10, "constraints": { "value_min":1, "value_max":15, "value_step":1 } }, "myVec3Array":{ "title": "myVec3Array", "type": "vector3[]", "defaultValue": [ [2,4,6], [1,3,5] ], "constraints": { "array_min_length":0, "array_max_length":3 } } } }, } ``` -------------------------------- ### SyntaxError Example Source: https://docs.lunalabs.io/docs/playable/common-issues/code/unexpected-token-name This is the error message encountered in the Unity Playworks Plugin window. ```text SyntaxError: Unexpected token name «shaft», expected punc «,» UnityEngine.Debug:LogError (object,UnityEngine.Object)  . : (object,Luna.Unity.EditorScripts.Logging.LogLevel,object) .⁇:  (object,object) .⁑/ :  (object,System.Diagnostics.DataReceivedEventArgs) System.Threading._ThreadPoolWaitCallback:PerformWaitCallback () ``` -------------------------------- ### Create Develop Build (Windows) Source: https://docs.lunalabs.io/docs/playable/command-line Execute the 'project:build' Jake task on Windows using the provided Node.js command to create a develop build. ```cmd > tools\node\win64\node.exe pipeline\node_modules\jake\bin\cli.js -f pipeline\Jakefile.js project:build ``` -------------------------------- ### Using Declarations Example Source: https://docs.lunalabs.io/docs/playable/code/plugin-compiler-v2 Shows how to use 'using' declarations for automatic disposal of resources like file streams. The resource remains in scope until the end of the block. ```csharp static int WriteLinesToFile(IEnumerable lines) { using var file = new System.IO.StreamWriter("WriteLines2.txt"); int skippedLines = 0; foreach (string line in lines) { if (!line.Contains("Second")) { file.WriteLine(line); } else { skippedLines++; } } // Notice how skippedLines is in scope here. return skippedLines; // file is disposed here } ``` -------------------------------- ### HTML with Data Attribute Source: https://docs.lunalabs.io/docs/playable/common-issues/js-playables/playground-fields-dont Example of an HTML list item with a custom data attribute storing animal type. ```html
  • Owl
  • ```