FANDOM


This custom Action allows you to change a menu's "Appear type" property at runtime. To use it, place the code below in a C# script named ActionChangeMenuAppearType.cs, and place the file in your custom Actions folder. For more on custom Actions and such folders, see this tutorial.

ActionChangeMenuAppearType.cs

using UnityEngine;
using System.Collections;
#if UNITY_EDITOR
using UnityEditor;
#endif

namespace AC
{

public class ActionChangeMenuAppearType : Action
{

public string menuName;
public AppearType newAppearType;


public ActionChangeMenuAppearType ()
{
this.isDisplayed = true;
category = ActionCategory.Menu;
title = "Change appear type";
}

override public float Run ()
{
Menu menu = AC.PlayerMenus.GetMenuWithName (menuName);
if (menu != null)
{
menu.appearType = newAppearType;
}
return 0f;
}

#if UNITY_EDITOR

override public void ShowGUI ()
{
menuName = EditorGUILayout.TextField ("Menu name:", menuName);
newAppearType = (AppearType) EditorGUILayout.EnumPopup ("New appear type:", newAppearType);

AfterRunningOption ();
}

#endif

}

}
Community content is available under CC-BY-SA unless otherwise noted.