You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
using UnityEngine; |
|
using UnityEngine.UI; |
|
using System; |
|
using System.Collections; |
|
|
|
namespace Fungus |
|
{ |
|
[CommandInfo("Scripting", |
|
"Get Text", |
|
"Gets the text property from a UI Text object and stores it in a string variable.")] |
|
|
|
[AddComponentMenu("")] |
|
public class GetText : Command |
|
{ |
|
[Tooltip("Text object to get text value from")] |
|
public Text textObject; |
|
|
|
[Tooltip("String variable to store the text value in")] |
|
[VariableProperty(typeof(StringVariable))] |
|
public Variable variable; |
|
|
|
public override void OnEnter() |
|
{ |
|
if (textObject != null) |
|
{ |
|
StringVariable stringVariable = variable as StringVariable; |
|
if (stringVariable != null) |
|
{ |
|
stringVariable.value = textObject.text; |
|
} |
|
} |
|
|
|
Continue(); |
|
} |
|
|
|
public override string GetSummary() |
|
{ |
|
if (textObject == null) |
|
{ |
|
return "Error: No text object selected"; |
|
} |
|
|
|
if (variable == null) |
|
{ |
|
return "Error: No variable selected"; |
|
} |
|
|
|
return textObject.name + " : " + variable.name; |
|
} |
|
|
|
public override Color GetButtonColor() |
|
{ |
|
return new Color32(235, 191, 217, 255); |
|
} |
|
} |
|
|
|
} |