- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 125
Actions and Variables
        Alex Lementuev edited this page Jan 18, 2017 
        ·
        12 revisions
      
    'Actions' provide a quick and easy way to execute arbitrary methods from Lunar Mobile Console.

You can register/unregister actions using the following API calls:
- 
LunarConsole.RegisterAction(name, callback)- registers action with name and callback
- 
LunarConsole.UnregisterAction(callback)- unregisters action with specified callback
- 
LunarConsole.UnregisterAction(name)- unregisters action with specified name
- 
LunarConsole.UnregisterAllActions(target)- unregisters ALL actions with specified target
Example:
using UnityEngine;
using LunarConsolePlugin;
public class TestActions : MonoBehaviour
{
    void Start()
    {
        LunarConsole.RegisterAction("Action-1", Action1);
        LunarConsole.RegisterAction("Action-2", Action2);
        LunarConsole.RegisterAction("Action-3", Action3);
    }
    void OnDestroy()
    {
        LunarConsole.UnregisterAllActions(this); // don't forget to unregister!
    }
    void Action1()
    {
        ...
    }
    void Action2()
    {
        ...
    }
    void Action3()
    {
        ...
    }
}
 
- Select a GameObjectfrom your scene and addLunar Console Actionscomponent to it:
 - Use ```Add``` and ```Remove``` buttons to register and unregister actions:
- Use ```Add``` and ```Remove``` buttons to register and unregister actions:  
 - Use ```Dont Destroy On Load``` checkbox to keep actions between scene loading
- Use ```Dont Destroy On Load``` checkbox to keep actions between scene loading
TBD