void Init() { if (initiated) { return; } initiated = true; uib = GetComponent <LevelBuilderUIButton>(); b = GetComponent <Button>(); hh = GetComponent <UIHoverHelp>(); hhOriginalTitle = hh.title; hhOriginalDescription = hh.description; if (!hh) { hh = gameObject.AddComponent <UIHoverHelp>(); hh.title = ""; hh.description = ""; } if (itemLevel > 1) { LockItem(); } }
void MoveToCurrentInstruction() { // // commented Debug.Log("move to current:"+CurrentInstruction().title); // helping = true; // Sometimes, the item we are trying to click is a little farther down the scroll window. Let's detect that and set scroll height appropriately. LevelBuilderUIButton uib = CurrentInstruction().go.GetComponent <LevelBuilderUIButton>(); if (uib) { PreventClickDrag sr = null; // PreventClickDrag is my method that overrides ScrollRect default ..... int timesToRecursiveCheckParent = 6; Transform currentParent = CurrentInstruction().go.transform; while (timesToRecursiveCheckParent > 0 && sr == null) { sr = currentParent.parent.GetComponent <PreventClickDrag>(); timesToRecursiveCheckParent--; currentParent = currentParent.parent; } if (sr) { sr.content.transform.localPosition = sr.contentStartPosition; // snap the scroll pos to the top before potentially modding it. // // commented Debug.Log("anchored pos of sr cont:"+sr.content.anchoredPosition.y); // // commented Debug.Log("rect anchor y:"+uib.transform.position.y); float ypos = uib.transform.position.y; // for world yPos, -461 is at the bottom of the screen, +360 is the top of the screen in real world positions. float contentHeight = sr.content.rect.height; // for content height, 575 would represent the entire height of the screen. Not sure how this translates to world units. int timesToRecurseMoveScrollbar = 9; while (ypos < 0 && timesToRecurseMoveScrollbar > 0) // ugly { timesToRecurseMoveScrollbar--; ypos = uib.transform.position.y; // sr.verticalScrollbar.value -= 0.1f; sr.content.anchoredPosition += new Vector2(0, 100); // // commented Debug.Log("sr vert scrol val:"+sr.verticalScrollbar.value); } // // commented Debug.Log("scroll rect pos:"+sr.verticalScrollbar.value); } else { // // commented Debug.Log("no sr found on:"+uib.name); } } // Posiiton the hover helper based on the intruction location. targetHoverTransform = CurrentInstruction().targetLocation.transform; HoverHelperManager.inst.SetHoverPosition(targetHoverTransform, false, true); // CurrentInstruction().hoverType); string title = CurrentInstruction().title; string description = CurrentInstruction().description; HoverHelperManager.inst.SetHelperText(title, description); HoverHelperManager.inst.SetTutorialButtonActive(true); TutorialManager.inst.restrictInputBig.SetActive(false); TutorialManager.inst.restrictInputSmall.SetActive(false); // // commented Debug.Log("both false."); switch (CurrentInstruction().restrictInput) { case RestrictInputUI.Big: TutorialManager.inst.restrictInputBig.SetActive(true); break; case RestrictInputUI.Small: TutorialManager.inst.restrictInputSmall.SetActive(true); break; case RestrictInputUI.None: TutorialManager.inst.restrictInputBig.SetActive(true); break; default: break; } }