chrisgregan
10 years ago
4 changed files with 128 additions and 0 deletions
@ -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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 54baf7aee38a7425ca4bd2addbfcfdcf |
||||
timeCreated: 1431530474 |
||||
licenseType: Free |
||||
MonoImporter: |
||||
serializedVersion: 2 |
||||
defaultReferences: [] |
||||
executionOrder: 0 |
||||
icon: {instanceID: 0} |
||||
userData: |
||||
assetBundleName: |
||||
assetBundleVariant: |
@ -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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -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…
Reference in new issue