Forum rules - please read before posting.

Resetting Input Variable Value

When my player inputted the wrong answer, I needed an action that reset it, so it didn't stay the next time they tried to enter one. With the help of Chris, this is what I got that worked.

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

namespace AC
{
[System.Serializable]
public class ActionResetVariable : Action
{
public string MenuName;
public string InputName;

public ActionResetVariable ()
{
this.isDisplayed = true;
title = "Variable: Reset";
}
override public float Run ()
{
AC.MenuInput inputBox = (AC.MenuInput) AC.PlayerMenus.GetElementWithName (MenuName, InputName);
inputBox.label = "";
return 0f;
}
#if UNITY_EDITOR
override public void ShowGUI ()
{
MenuName = EditorGUILayout.TextField ("Menu Name:", MenuName);
InputName = EditorGUILayout.TextField ("Input Field Name:", InputName);
AfterRunningOption ();
}
}
}

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.