//used only input field message -> not connect content list only for ui arrange public void InstantiateMessage(contentType type, string dataString) { switch (type) { case contentType.message: newBubbleObject = messagePrefab; break; case contentType.button: newBubbleObject = buttonPrefab; break; } if (curBubble != null) { exBubble = curBubble.GetComponent <RectTransform>(); } //instantiate exmessage curBubble = Instantiate(newBubbleObject); Buble curMessageBubble = curBubble.GetComponent <Buble>(); //register curmessage to curspace curBubble.transform.SetParent(bubbleSpace[0]); //resize bubble bg float bgsize = curDialogBg.sizeDelta.y - inputFieldSize - 10; curDialogBg.offsetMax = new Vector2(0, bgsize); curDialogBg.offsetMin = new Vector2(0, 0); curDialogBg.transform.localPosition = Vector3.zero; //link on bubble size curMessageBubble.onBubbleResize += RepositionBubblePanel; //set text area to right anchor(input answer only) curMessageBubble.ui_const.alignment = TMPro.TextAlignmentOptions.MidlineRight; curMessageBubble.myString = dataString; }
public void InstantiateMessage(Content contentData, string dataString) { actiontype type = actiontype.notSet; string actionValue = null; switch (contentData.type) { case contentType.message: newBubbleObject = messagePrefab; break; case contentType.button: newBubbleObject = buttonPrefab; break; } //register ex message for reposition after instantiate curmessage if (curBubble != null) { exBubble = curBubble.GetComponent <RectTransform>(); } //instantiate exmessage curBubble = Instantiate(newBubbleObject); Buble curMessageBubble = curBubble.GetComponent <Buble>(); if (contentData.type == contentType.button) { curMessageBubble.myactionType = contentData.button.type; } //register curmessage to curspace curBubble.transform.SetParent(bubbleSpace[0]); //link on bubble size curMessageBubble.onBubbleResize += RepositionBubblePanel; curMessageBubble.myString = dataString; curMessageBubble.myId = contentData.id; curMessageBubble.myDialogNumber = contentData.dialogNumber; }
private void OnEnable() { bubbleGenerator = this.GetComponent <BubleGenerator>(); curInputResult = InputResultState.empty; curDialogState = DialogState.waitTrigger; ui_inputField = inputPannel.GetComponentInChildren <Buble>(); inputPannel.SetActive(false); tabmanager = tabManager; a_sources = audioPlayer.GetComponentsInChildren <AudioSource>(); ARContentOnId = new string[2]; for (int i = 0; i < ARContentOnId.Length; i++) { ARContentOnId[i] = "null"; } VuforiaRuntime.Instance.InitVuforia(); //init vuforia //get bundle for (int i = 0; i < DataSorter.instance.List_bundle.Count; i++) { for (int j = 0; j < list_ArContent.Length; j++) { if (list_ArContent[j].myArId == DataSorter.instance.List_bundle[i].name) { GameObject arBundles = Instantiate(DataSorter.instance.List_bundle[i].loadObject); arBundles.transform.parent = list_ArContent[i].transform.GetChild(0); arBundles.transform.localPosition = Vector3.zero; arBundles.transform.localRotation = Quaternion.identity; arBundles.transform.localScale = Vector3.one; Debug.Log("budle" + list_ArContent[i].myArId + " - is loaded on scene"); } } } contentTypingEnd = true; }
public void TestSortingAlgoritmOutput() { Buble bubble = new Buble(5, 1, 4, 2, 8); Assert.That(() => bubble.Sort(), Is.EqualTo("1 2 4 5 8")); }
void RepositionBubblePanel(float movedHeight) { RectTransform curRect = curBubble.GetComponent <RectTransform>(); curRect.localScale = new Vector3(1, 1, 1); float yposition; Buble curBubleComponent = curBubble.GetComponent <Buble>(); if (exBubble == null) { exHeight = 0; yposition = 0; } else { exHeight = exBubble.GetChild(0).GetComponent <RectTransform>().sizeDelta.y; yposition = Mathf.Abs(exBubble.transform.localPosition.y); } if (DialogSequencer.curContentIndex == 0) { GameObject dialogBg = Instantiate(dialogBgPrefab); curDialogBg = dialogBg.GetComponent <RectTransform>(); curDialogBg.parent = curBubble.transform; curDialogBg.transform.SetAsFirstSibling(); curDialogBg.transform.localPosition = Vector3.zero; Debug.Log("content index is zero, will instantiate dialog prefabs"); if (DataSorter.instance.curDialogIndex != 0) { yposition = Mathf.Abs(exBubble.transform.localPosition.y - 30); } Debug.Log("reset local position" + curDialogBg.transform.localPosition); // curDialogBg.sizeDelta = new Vector2(1, 1); curDialogBg.localScale = new Vector3(1, 1, 1); } curBubble.GetComponent <Buble>().SetUiExpandZero(); curBubble.transform.localPosition = new Vector3(0, (yposition + exHeight) * -1, 0); float bgsize = curDialogBg.sizeDelta.y + curBubble.GetComponent <Buble>().bgImage.sizeDelta.y; // exHeight = curBubble.GetComponent<Buble>().bgImage.sizeDelta.y+30; exHeight = curBubble.GetComponent <Buble>().bgImage.sizeDelta.y + 10; float scrollAreaSizeY = Mathf.Abs(bubbleSpace[0].GetChild(bubbleSpace[0].childCount - 1).transform.localPosition.y) + exHeight; if (scrollArea.offsetMax.y <= scrollAreaSizeY) { overedViewportDefault = true; } if (overedViewportDefault) { scrollArea.offsetMax = new Vector2(0, scrollAreaSizeY); scrollArea.offsetMin = new Vector2(0, 0); } //bgsize = curDialogBg.sizeDelta.y + curBubble.GetComponent<Buble>().bgImage.sizeDelta.y; Debug.Log("cur background's size" + curBubble.GetComponent <Buble>().bgImage.sizeDelta.y + curBubble.GetComponent <Buble>().myId); curDialogBg.offsetMax = new Vector2(0, bgsize); curDialogBg.offsetMin = new Vector2(0, 0); curDialogBg.transform.localPosition = Vector3.zero; //broke the link curBubleComponent.onBubbleResize -= RepositionBubblePanel; if (curBubleComponent.bubbletype == Buble._bubbletype.message) { curBubleComponent.ui_const.color = curBubleComponent.myTextColor; //start typing text curBubleComponent.ui_const.GetComponent <TextTyper>().OnStartTyping(); } else { } }