Browse Source

Added Set Text and Get Text commands

Set and get text property from a UI text object.
master
chrisgregan 10 years ago
parent
commit
107f4f4756
  1. 57
      Assets/Fungus/Flowchart/Scripts/Commands/GetText.cs
  2. 12
      Assets/Fungus/Flowchart/Scripts/Commands/GetText.cs.meta
  3. 47
      Assets/Fungus/Flowchart/Scripts/Commands/SetText.cs
  4. 12
      Assets/Fungus/Flowchart/Scripts/Commands/SetText.cs.meta

57
Assets/Fungus/Flowchart/Scripts/Commands/GetText.cs

@ -0,0 +1,57 @@
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);
}
}
}

12
Assets/Fungus/Flowchart/Scripts/Commands/GetText.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 54baf7aee38a7425ca4bd2addbfcfdcf
timeCreated: 1431530474
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

47
Assets/Fungus/Flowchart/Scripts/Commands/SetText.cs

@ -0,0 +1,47 @@
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
namespace Fungus
{
[CommandInfo("Scripting",
"Set Text",
"Sets the text property on a UI Text object.")]
[AddComponentMenu("")]
public class SetText : Command
{
[Tooltip("Text object to set text on")]
public Text textObject;
[Tooltip("String value to assign to the text object")]
public StringData stringData;
public override void OnEnter()
{
if (textObject != null)
{
textObject.text = stringData.Value;
}
Continue();
}
public override string GetSummary()
{
if (textObject == null)
{
return "Error: No text object selected";
}
return textObject.name + " : " + stringData.Value;
}
public override Color GetButtonColor()
{
return new Color32(235, 191, 217, 255);
}
}
}

12
Assets/Fungus/Flowchart/Scripts/Commands/SetText.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 7ec5abc702c3f400b91bbeb2b8328d02
timeCreated: 1431529735
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save