-
-
Save tantzygames/514425b9bcee2895b417097f5ccb1a46 to your computer and use it in GitHub Desktop.
Routine Description Editor from http://www.tantzygames.com/blog/wysiwyg-text-editing-for-unity-mobile/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
using TMPro; | |
public class RoutineEditor : MonoBehaviour { | |
public RoutineMenu routineMenu; | |
public ImageIO imageIO; | |
[Header("Routine Editor")] | |
public TMP_InputField inputName; | |
public Toggle isPublic; | |
public TMP_InputField inputDescription; | |
EventSender descriptionEvents; | |
public Button buttonSaveEdit; | |
public Button buttonPreview; | |
public Button buttonCancel; | |
public Popup addImage; | |
public TMP_InputField addImageInput; | |
public TextMeshProUGUI addImagePlaceholder; | |
public Popup addLink; | |
public TMP_InputField addLinkInput1; | |
public TextMeshProUGUI addLinkPlaceholder1; | |
public TMP_InputField addLinkInput2; | |
public TextMeshProUGUI addLinkPlaceholder2; | |
public ScrollRect descriptionScrollview; | |
public Transform descriptionContent; | |
[Header("Format Buttons")] | |
[SerializeField] | |
Toggle buttonBold; | |
[SerializeField] | |
Toggle buttonItalic; | |
[SerializeField] | |
Toggle buttonUnderline; | |
[SerializeField] | |
Button buttonLink; | |
[SerializeField] | |
Button buttonText; | |
[SerializeField] | |
Button buttonImage; | |
[SerializeField] | |
Button buttonImageLink; | |
[SerializeField] | |
public UIDropdown addDropdown; | |
[Header("Description Blocks")] | |
[TextArea] | |
public string defaultText; | |
public float defaultHeight; | |
public string normalText; | |
public float normalHeight; | |
public string imageText; | |
public ButtonDescription buttonDescription; | |
ButtonDescription selectedBlock; | |
public ButtonDescription SelectedBlock | |
{ | |
get { return selectedBlock; } | |
set { selectedBlock = value; } | |
} | |
string description = ""; | |
public string Description | |
{ | |
get { return description; } | |
set { description = value; } | |
} | |
List<ButtonDescription> descBlocks = new List<ButtonDescription>(); | |
List<ButtonDescription> imageBlocks = new List<ButtonDescription>(); | |
//List<TextMeshProUGUI> textBlocks = new List<TextMeshProUGUI>(); | |
List<Image> images = new List<Image>(); | |
Dictionary<string, ButtonDescription> spriteBlocks = new Dictionary<string, ButtonDescription>(); | |
public bool isBold; | |
public bool isItalic; | |
public bool isUnderline; | |
ButtonRoutine routineButtonToEdit; | |
PopupWarning popupWarning; | |
// To store values for Cancel | |
string tempName = ""; | |
string tempDescription = ""; | |
bool tempPublic = true; | |
public bool IsChanged | |
{ | |
get | |
{ | |
if (inputName.text != tempName || | |
Description != tempDescription || | |
isPublic.isOn != tempPublic) | |
{ | |
return true; | |
} | |
for (int i = 0; i < descBlocks.Count; i++) | |
{ | |
if (descBlocks[i].isChanged) | |
{ | |
return true; | |
} | |
} | |
return false; | |
} | |
} | |
//System.Text.StringBuilder description; | |
// Use this for initialization | |
void Start () { | |
//inputDescription.on | |
buttonSaveEdit.onClick.AddListener(SaveRoutineEdit); | |
buttonCancel.onClick.AddListener(CancelRoutineEdit); | |
buttonPreview.onClick.AddListener(PreviewEdit); | |
//inputName.OnSelect.AddListener(EditName); | |
//descriptionEvents = inputDescription.GetComponent<EventSender>(); | |
// descriptionEvents.PointerClick += EditDescription; | |
inputName.onEndEdit.AddListener(UpdateName); | |
buttonBold.onValueChanged.AddListener(MakeBold); | |
buttonItalic.onValueChanged.AddListener(MakeItalic); | |
buttonUnderline.onValueChanged.AddListener(MakeUnderline); | |
buttonLink.onClick.AddListener(AddLink); | |
buttonText.onClick.AddListener(CreateTextBlock); | |
buttonImage.onClick.AddListener(CreateImageBlock); | |
//buttonImageLink.onClick.AddListener(AddImageLink); | |
//addDropdown.onSelected += SelectAdd; | |
imageIO.GotSprite += ReturnSprite; | |
imageIO.GotError += ReturnSpriteError; | |
} | |
public void Initialize(ButtonRoutine buttonRoutine = null) | |
{ | |
if (buttonRoutine != routineButtonToEdit) | |
ForceInitialize(buttonRoutine); | |
} | |
void ForceInitialize(ButtonRoutine buttonRoutine = null) | |
{ | |
buttonBold.isOn = false; | |
isBold = false; | |
buttonItalic.isOn = false; | |
isItalic = false; | |
buttonUnderline.isOn = false; | |
isUnderline = false; | |
if (buttonRoutine == null) | |
{ | |
(descriptionContent as RectTransform).anchoredPosition = new Vector2(0, 0); | |
routineButtonToEdit = null; | |
inputName.text = ""; | |
isPublic.isOn = true; | |
Description = ""; | |
CreateDefaultTextBlock(); | |
} | |
else | |
{ | |
(descriptionContent as RectTransform).anchoredPosition = new Vector2(0, 0); | |
routineButtonToEdit = buttonRoutine; | |
inputName.text = buttonRoutine.routineInfo.Name; | |
tempName = buttonRoutine.routineInfo.Name; | |
isPublic.isOn = buttonRoutine.IsPublic; | |
tempPublic = buttonRoutine.IsPublic; | |
Description = routineButtonToEdit.routineInfo.Description; | |
tempDescription = routineButtonToEdit.routineInfo.Description; | |
ParseDescription(); | |
} | |
} | |
void ClearDescription() | |
{ | |
images.Clear(); | |
imageBlocks.Clear(); | |
spriteBlocks.Clear(); | |
//textBlocks.Clear(); | |
for (int i = 0; i < descBlocks.Count; i++) | |
{ | |
//if (descBlocks[i] != defaultButtonDescription) | |
if (descBlocks[i]) | |
Destroy(descBlocks[i].gameObject); | |
} | |
descBlocks.Clear(); | |
} | |
void ParseDescription() | |
{ | |
ClearDescription(); | |
Debugger.Log("Getting " + routineButtonToEdit.routineInfo.Name + " Description"); | |
if (Description.Contains("<img>")) | |
{ | |
List<string> imageurls = new List<string>(); | |
images = new List<Image>(); | |
GetDescriptionImage(Description, imageurls, true); | |
} | |
else | |
{ | |
ProcessText(Description); | |
} | |
//gotDescription = true; | |
} | |
void GetDescriptionImage(string description, List<string> imageurls, bool open) | |
{ | |
int iStart = description.IndexOf("<img>"); | |
int iLast = description.IndexOf("</img>"); | |
int iLength = iLast - (iStart + 5); | |
if (iStart > 0) | |
ProcessText(description.Substring(0, iStart)); | |
string imagestring = description.Substring(iStart + 5, iLength); | |
if (imagestring.Contains("<url>")) | |
{ | |
int uStart = imagestring.IndexOf("<url>"); | |
int uLength = imagestring.IndexOf("</url>") - (uStart + 5); | |
string linkurl = imagestring.Substring(uStart + 5, uLength); | |
string imageurl = imagestring.Substring(0, uStart); | |
CreateImageLink(imageurl, linkurl); | |
if (imageIO.Sprites.ContainsKey(imageurl)) | |
ReturnSprite(imageurl); | |
else if (!imageurl.Equals("")) | |
imageurls.Add(imageurl); | |
} | |
else | |
{ | |
CreateImageBlock(imagestring); | |
if (imageIO.Sprites.ContainsKey(imagestring)) | |
ReturnSprite(imagestring); | |
else if (!imagestring.Equals("")) | |
imageurls.Add(imagestring); | |
} | |
description = description.Substring(iLast + 6); | |
if (description.Length > 0) | |
{ | |
if (description.Contains("<img>")) | |
{ | |
GetDescriptionImage(description, imageurls, open); | |
} | |
else | |
{ | |
ProcessText(description); | |
GetImages(imageurls); | |
} | |
} | |
else | |
{ | |
GetImages(imageurls); | |
} | |
} | |
void ProcessText(string text) | |
{ | |
if (!text.Contains("<p>")) | |
{ | |
CreateTextBlock(text); | |
return; | |
} | |
int iStart = text.IndexOf("<p>"); | |
int iLast = text.IndexOf("</p>"); | |
int iLength = iLast - (iStart + 3); | |
if (iStart > 0) | |
CreateTextBlock(text.Substring(0, iStart)); | |
string textstring = text.Substring(iStart + 3, iLength); | |
CreateTextBlock(textstring); | |
text = text.Substring(iLast + 4); | |
if (text.Length > 0) | |
{ | |
if (text.Contains("<p>")) | |
{ | |
ProcessText(text); | |
} | |
else | |
{ | |
CreateTextBlock(text); | |
} | |
} | |
} | |
void GetImages(List<string> urls) | |
{ | |
imageIO.GetSprites(urls); | |
} | |
void GetImage(string url) | |
{ | |
if (selectedBlock != null) | |
selectedBlock.WaitForImage(); | |
imageIO.GetSprite(url); | |
} | |
void ReturnSprite(string url) | |
{ | |
if (spriteBlocks.ContainsKey(url)) | |
{ | |
if (imageIO.Sprites.ContainsKey(url)) | |
spriteBlocks[url].SetImage(imageIO.Sprites[url]); | |
else | |
spriteBlocks[url].ImageDownloadError(); | |
} | |
} | |
void ReturnSpriteError(string url) | |
{ | |
if (spriteBlocks.ContainsKey(url)) | |
spriteBlocks[url].ImageDownloadError(); | |
} | |
void CreateTextBlock(string text) | |
{ | |
//Debugger.Log("Create text: " + text); | |
// Remove return at beginning of text block | |
if (text.Substring(0, 1).Contains("\n")) | |
text = text.Substring(1); | |
GameObject go = Instantiate(buttonDescription.gameObject, descriptionContent); | |
ButtonDescription buttonDesc = go.GetComponent<ButtonDescription>(); | |
go.SetActive(true); | |
buttonDesc.Initialize(ButtonDescription.Type.text, false, text); | |
descBlocks.Add(buttonDesc); | |
} | |
void CreateImageBlock(string imageurl) | |
{ | |
////Debugger.Log("Create image: " + url); | |
GameObject go = Instantiate(buttonDescription.gameObject, descriptionContent); | |
ButtonDescription buttonDesc = go.GetComponent<ButtonDescription>(); | |
buttonDesc.Initialize(ButtonDescription.Type.image, false, imageurl); | |
descBlocks.Add(buttonDesc); | |
spriteBlocks[imageurl] = buttonDesc; | |
} | |
void CreateImageLink(string imageurl, string linkurl) | |
{ | |
//Debugger.Log("Create button: " + linkurl); | |
if (!linkurl.Contains("http")) | |
{ | |
linkurl = "http://" + linkurl; | |
} | |
GameObject go = Instantiate(buttonDescription.gameObject, descriptionContent); | |
ButtonDescription buttonDesc = go.GetComponent<ButtonDescription>(); | |
buttonDesc.Initialize(ButtonDescription.Type.imageLink, false, imageurl, linkurl); | |
descBlocks.Add(buttonDesc); | |
spriteBlocks[imageurl] = buttonDesc; | |
} | |
void CreateDefaultTextBlock() | |
{ | |
ClearDescription(); | |
GameObject go = Instantiate(buttonDescription.gameObject, descriptionContent); | |
ButtonDescription buttonDesc = go.GetComponent<ButtonDescription>(); | |
go.SetActive(true); | |
buttonDesc.Initialize(ButtonDescription.Type.text, true); | |
descBlocks.Add(buttonDesc); | |
} | |
void CreateTextBlock() | |
{ | |
GameObject go = Instantiate(buttonDescription.gameObject, descriptionContent); | |
ButtonDescription buttonDesc = go.GetComponent<ButtonDescription>(); | |
go.SetActive(true); | |
buttonDesc.Initialize(ButtonDescription.Type.text, false); | |
descBlocks.Add(buttonDesc); | |
MoveToBottom(); | |
} | |
void CreateImageBlock() | |
{ | |
GameObject go = Instantiate(buttonDescription.gameObject, descriptionContent); | |
ButtonDescription buttonDesc = go.GetComponent<ButtonDescription>(); | |
buttonDesc.Initialize(ButtonDescription.Type.imageLink, false); | |
go.SetActive(true); | |
descBlocks.Add(buttonDesc); | |
MoveToBottom(); | |
} | |
void MoveToBottom() | |
{ | |
if ((descriptionContent as RectTransform).rect.height > (descriptionScrollview.transform as RectTransform).rect.height) | |
{ | |
if (descriptionScrollview.verticalNormalizedPosition > 0) | |
StartCoroutine(ScrollToBottom()); | |
} | |
} | |
IEnumerator ScrollToBottom() | |
{ | |
float time = 0.2f; | |
float elapsedTime = 0; | |
while (elapsedTime < time) | |
{ | |
descriptionScrollview.verticalNormalizedPosition = Mathf.Lerp(descriptionScrollview.verticalNormalizedPosition, 0, elapsedTime / time); | |
elapsedTime += Time.deltaTime; | |
yield return null; | |
} | |
descriptionScrollview.verticalNormalizedPosition = 0; | |
} | |
public void ResetEditor() | |
{ | |
if (IsChanged) | |
{ | |
ForceInitialize(routineButtonToEdit); | |
} | |
isBold = false; | |
isItalic = false; | |
isUnderline = false; | |
} | |
void SaveRoutineEdit() | |
{ | |
if (inputName.text.Trim() == "") | |
{ | |
MenuManager.OpenWarning("Invalid Name", "Please give your routine a name.", true, false); | |
return; | |
} | |
if (isBold) | |
buttonBold.isOn = false; | |
if (isItalic) | |
buttonItalic.isOn = false; | |
if (isUnderline) | |
buttonUnderline.isOn = false; | |
UpdateBlockText(); | |
routineMenu.SaveRoutineEdit(inputName.text, Description, isPublic.isOn); | |
} | |
void PreviewEdit() | |
{ | |
UpdateBlockText(); | |
if (Description.Equals("")) | |
return; | |
if (routineButtonToEdit != null) | |
routineMenu.popupRoutineInfo.Open(routineButtonToEdit.routineInfo); | |
else | |
{ | |
string author = ""; | |
if (AccountManager.CurrentAccount != null) | |
author = AccountManager.CurrentAccount.AccountName; | |
RoutineInfo routineinfo = new RoutineInfo("", inputName.text, author, Description); | |
routineMenu.popupRoutineInfo.Open(routineinfo); | |
} | |
} | |
public void LeaveEditor() | |
{ | |
if (!IsChanged) | |
{ | |
ResetEditor(); | |
MenuManager.NavBack(); | |
} | |
else | |
{ | |
if (routineButtonToEdit != null) | |
{ | |
popupWarning = MenuManager.OpenWarning("Keep Changes?", "Would you like to save your changes?", true, true); | |
} | |
else | |
{ | |
popupWarning = MenuManager.OpenWarning("Keep Routine?", "Would you like to save your new routine?", true, true); | |
} | |
popupWarning.buttonTick.onClick.AddListener(ConfirmSave); | |
popupWarning.buttonCross.onClick.AddListener(CancelSave); | |
} | |
} | |
void ConfirmSave() | |
{ | |
SaveRoutineEdit(); | |
CloseSave(); | |
} | |
void CancelSave() | |
{ | |
ResetEditor(); | |
CloseSave(); | |
} | |
void CloseSave() | |
{ | |
popupWarning.buttonTick.onClick.RemoveListener(ConfirmSave); | |
popupWarning.buttonCross.onClick.RemoveListener(CancelSave); | |
MenuManager.NavBack(); | |
} | |
public void CancelRoutineEdit() | |
{ | |
if (!IsChanged) | |
{ | |
ResetEditor(); | |
return; | |
} | |
if (routineButtonToEdit != null) | |
{ | |
popupWarning = MenuManager.OpenWarning("Undo Changes?", "This will undo your changes. Do you want to proceed?", true, true); | |
} | |
else | |
{ | |
popupWarning = MenuManager.OpenWarning("Cancel New Routine?", "Do you want to cancel your new routine?", true, true); | |
} | |
popupWarning.buttonTick.onClick.AddListener(ConfirmCancelEdit); | |
popupWarning.buttonCross.onClick.AddListener(CancelCancelEdit); | |
} | |
void ConfirmCancelEdit() | |
{ | |
if (routineButtonToEdit) | |
{ | |
routineButtonToEdit.routineInfo.Name = tempName; | |
routineButtonToEdit.Name = tempName; | |
routineButtonToEdit.Description = tempDescription; | |
routineButtonToEdit.IsPublic = tempPublic; | |
} | |
ResetEditor(); | |
CancelCancelEdit(); | |
} | |
void CancelCancelEdit() | |
{ | |
popupWarning.buttonTick.onClick.RemoveListener(ConfirmCancelEdit); | |
popupWarning.buttonCross.onClick.RemoveListener(CancelCancelEdit); | |
} | |
void EditName(string text) | |
{ | |
inputName.MoveTextEnd(true); | |
} | |
void UpdateName(string text) | |
{ | |
if (routineButtonToEdit != null) | |
{ | |
routineButtonToEdit.routineInfo.Name = text; | |
routineButtonToEdit.Name = text; | |
} | |
} | |
void EditDescription() | |
{ | |
inputDescription.MoveTextEnd(true); | |
} | |
void MakeBold(bool isOn) | |
{ | |
if (isOn) | |
{ | |
isBold = true; | |
if (SelectedBlock != null) | |
{ | |
if (SelectedBlock.TextSelected) | |
{ | |
Debugger.Log("Process Tags <b>"); | |
//ProcessTags("<b>", "</b>"); | |
SelectedBlock.ProcessSelection(0); | |
buttonBold.isOn = false; | |
isBold = false; | |
} | |
} | |
} | |
else | |
{ | |
for (int i = 0; i < descBlocks.Count; i++) | |
{ | |
if (descBlocks[i].blockType == ButtonDescription.Type.text) | |
{ | |
descBlocks[i].SetBold(false); | |
} | |
} | |
isBold = false; | |
} | |
} | |
void MakeItalic(bool isOn) | |
{ | |
if (isOn) | |
{ | |
isItalic = true; | |
if (SelectedBlock != null) | |
{ | |
if (SelectedBlock.TextSelected) | |
{ | |
Debugger.Log("Process Tags <i>"); | |
SelectedBlock.ProcessSelection(1); | |
buttonItalic.isOn = false; | |
isItalic = false; | |
} | |
} | |
} | |
else | |
{ | |
for (int i = 0; i < descBlocks.Count; i++) | |
{ | |
if (descBlocks[i].blockType == ButtonDescription.Type.text) | |
{ | |
descBlocks[i].SetItalic(false); | |
} | |
} | |
isItalic = false; | |
} | |
} | |
void MakeUnderline(bool isOn) | |
{ | |
if (isOn) | |
{ | |
isUnderline = true; | |
if (SelectedBlock != null) | |
{ | |
if (SelectedBlock.TextSelected) | |
{ | |
Debugger.Log("Process Tags <i>"); | |
SelectedBlock.ProcessSelection(2); | |
buttonUnderline.isOn = false; | |
isUnderline = false; | |
} | |
} | |
} | |
else | |
{ | |
for (int i = 0; i < descBlocks.Count; i++) | |
{ | |
if (descBlocks[i].blockType == ButtonDescription.Type.text) | |
{ | |
descBlocks[i].SetUnderline(false); | |
} | |
} | |
isUnderline = false; | |
} | |
} | |
public bool waitingForLink = false; | |
public void AddLink() | |
{ | |
if (SelectedBlock != null) | |
{ | |
if (selectedBlock.blockType == ButtonDescription.Type.text) | |
{ | |
addLink.TitleText = "Add Link"; | |
if (selectedBlock.TextSelected) | |
{ | |
addLinkInput1.text = selectedBlock.GetSelectedLink(); | |
addLinkInput2.text = selectedBlock.GetSelectedDisplay(); | |
} | |
else | |
{ | |
addLinkPlaceholder1.text = "Link url..."; | |
addLinkPlaceholder2.text = "Display text (opt)..."; | |
} | |
addLink.buttonTick.onClick.AddListener(InsertLink); | |
addLink.buttonCross.onClick.AddListener(CloseLink); | |
addLink.Open(); | |
} | |
else | |
{ | |
EditImageUrl(selectedBlock); | |
} | |
waitingForLink = false; | |
} | |
else | |
{ | |
waitingForLink = true; | |
popupWarning = MenuManager.OpenWarning("Choose Text Block", "Please choose a block for the link.", true, false); | |
} | |
} | |
void InsertLink() | |
{ | |
if (addLinkInput1.text == "") | |
{ | |
if (addLinkInput2.text == "") | |
{ | |
CloseLink(); | |
} | |
else | |
{ | |
selectedBlock.InsertLink(addLinkInput1.text, addLinkInput2.text); | |
CloseLink(); | |
} | |
} | |
else | |
{ | |
string displayText; | |
if (addLinkInput2.text == "") | |
displayText = addLinkInput1.text; | |
else | |
displayText = addLinkInput2.text; | |
selectedBlock.InsertLink(addLinkInput1.text, displayText); | |
CloseLink(); | |
} | |
} | |
void CloseLink() | |
{ | |
addLink.buttonTick.onClick.RemoveListener(InsertLink); | |
addLink.buttonCross.onClick.RemoveListener(CloseLink); | |
addLinkInput1.text = ""; | |
addLinkInput2.text = ""; | |
addLink.Close(); | |
} | |
public void EditImageUrl(ButtonDescription buttondesc) | |
{ | |
if (buttondesc.EditText != "") | |
addLinkInput1.text = buttondesc.EditText; | |
if (buttondesc.Url != "") | |
addLinkInput2.text = buttondesc.Url; | |
if (selectedBlock != buttondesc) | |
{ | |
if (selectedBlock.TextSelected) | |
selectedBlock.DeselectText(); | |
selectedBlock = buttondesc; | |
} | |
EditImageUrl(); | |
} | |
public void EditImageUrl() | |
{ | |
addLink.TitleText = "Add Image"; | |
addLinkPlaceholder1.text = "Image url..."; | |
addLinkPlaceholder2.text = "Link url (opt)..."; | |
addLink.buttonTick.onClick.AddListener(ProcessImageUrl); | |
addLink.buttonCross.onClick.AddListener(CloseImageUrl); | |
addLink.Open(); | |
} | |
void ProcessImageUrl() | |
{ | |
if (addLinkInput1.text == "") | |
{ | |
selectedBlock.RemoveImage(); | |
UpdateBlockText(); | |
CloseImageUrl(); | |
return; | |
} | |
bool changed = false; | |
if (addLinkInput1.text != selectedBlock.EditText) | |
{ | |
changed = true; | |
spriteBlocks.Remove(selectedBlock.EditText); | |
selectedBlock.SetImageUrl(addLinkInput1.text); | |
spriteBlocks[addLinkInput1.text] = selectedBlock; | |
if (imageIO.Sprites.ContainsKey(addLinkInput1.text)) | |
ReturnSprite(addLinkInput1.text); | |
else | |
GetImage(addLinkInput1.text); | |
} | |
if (addLinkInput2.text != selectedBlock.Url) | |
{ | |
changed = true; | |
selectedBlock.Url = addLinkInput2.text; | |
} | |
if (changed) | |
{ | |
UpdateBlockText(); | |
} | |
CloseImageUrl(); | |
} | |
void CloseImageUrl() | |
{ | |
addLink.buttonTick.onClick.RemoveListener(ProcessImageUrl); | |
addLink.buttonCross.onClick.RemoveListener(CloseImageUrl); | |
addLinkInput1.text = ""; | |
addLinkInput2.text = ""; | |
addLink.Close(); | |
} | |
public void UpdateBlockText() | |
{ | |
StringBuilder builder = new StringBuilder(); | |
for (int i = 0; i < descBlocks.Count; i++) | |
{ | |
if (!descBlocks[i].EditText.Equals("")) | |
builder.Append(descBlocks[i].BlockText); | |
} | |
Description = builder.ToString(); | |
Debugger.Log("UpdateBlockText = " + Description.Replace('>', ')').Replace('<', '(')); | |
if (routineButtonToEdit != null) | |
{ | |
routineButtonToEdit.routineInfo.Description = Description; | |
} | |
routineMenu.popupRoutineInfo.Reload = true; | |
} | |
public void UpdateBlockPosition() | |
{ | |
ButtonDescription[] bds = descriptionContent.GetComponentsInChildren<ButtonDescription>(); | |
List<ButtonDescription> newBlocks = new List<ButtonDescription>(); | |
for (int i = 0; i < bds.Length; i++) | |
{ | |
if (descBlocks.Contains(bds[i])) | |
{ | |
newBlocks.Add(bds[i]); | |
} | |
} | |
descBlocks = newBlocks; | |
UpdateBlockText(); | |
} | |
public void RemoveBlock(ButtonDescription block) | |
{ | |
descBlocks.Remove(block); | |
Destroy(block.gameObject); | |
UpdateBlockPosition(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment