MINIMUM_DISTANCE = 6 IMAGE_HEIGHT = 3 local mainCamera local player local fImage_Path = "UIB/Bassets/press-f" local alertImage_Path = "UIB/Bassets/HL_Alert" local F_Image = nil local alertImage = nil local fruitWall local isRequiredActionComplete = false function Start() player = TransformEx.MyPlayerTransform() loadAsync("NPCName/ShowNPCDialogue",onLoadNpcDialogue) --loadAsync("HUD/HUD_ToastMsg-Interact",onLoadToast) local Platformtext = CS.GMS.WPlatform.webGLPlatform == CS.WoogiWorld.WebGLPlatform.ios and "Touch the green" or "Press" Platformtext = Platformtext .. "F to Learn about the Mega Pi-Bot!" CS.Extend.RegisterToastMsg(transform,Platformtext,OnPressF,"f",2) luaEvent:AddEventListener('OnEnableMegaPibotInteraction',this, OnEnableInteraction) end function EnableInteractionImages() if isInteractionEnabled == false then local text = CS.GMS.WPlatform.webGLPlatform == CS.WoogiWorld.WebGLPlatform.ios and "Touch the green F to Learn about the Mega Pi-Bot!" or "Press F to Learn about the Mega Pi-Bot!" CS.Extend.RegisterToastMsg(transform,text,OnPressF,"f",2) loadAsync("NPCName/ShowNPCDialogue",onLoadNpcDialogue) isInteractionEnabled = true end end function OnEnableInteraction() EnableInteractionImages() isRequiredActionComplete = false flagForinteraction = true boolToMakeCanvasVisible = true end function onLoadNpcDialogue(_obj) if IsExist(_obj) then local _go = newObject(_obj) bubblePopup = _go.transform bubblePopup:SetParent(transform) bubblePopup.localScale = Vector3(-0.65, 3, 0.65);--Vector3.one bubblePopup.localPosition = Vector3(0, 2, 0); bubblePopup.localEulerAngles = Vector3.zero loadAsyncSprite(fImage_Path,function(image)--Uploading F-image if IsExist(image) then F_Image = image else print('Imaga is'..image) end end) loadAsyncSprite(alertImage_Path,function(image)--Uploading Alert image if IsExist(image) then alertImage = image bubblePopup.transform:SetImage("showLayer/name/Image",alertImage) else print('Imaga is'..image) end end) end end function OnPressF() isRequiredActionComplete = true OnDisableInteraction() CS.GameManager.PlayerMovement(false) luaEvent:DispatchEvent('OpenMegaPiBotText') end function OnDisableInteraction() isRequiredActionComplete = true if (bubblePopup ~= nil) then -- bubblePopup.gameObject:SetActive(false) GameObject.Destroy(bubblePopup.gameObject) isInteractionEnabled = false end luaEvent:RemoveEventListener('keyboard.F',this) CS.Extend.CloseToastMsg() CS.Extend.UnregisterToastMsg(transform) end function onLoadToast(prefab) if IsExist(prefab) then local go = newObject(prefab) go.name = prefab.name local tf = go.transform toast = tf.gameObject print(transform:UIroot()) local rectTf = go:GetComponent(typeof(UnityEngine.RectTransform)) local preRectTf = prefab:GetComponent(typeof(UnityEngine.RectTransform)) tf:SetParent(transform:UIroot()) tf.localScale = Vector3.one tf.localEulerAngles =Vector3.one tf.rotation = Quaternion(0,0,0,0) rectTf.sizeDelta = preRectTf.sizeDelta rectTf.anchorMin = preRectTf.anchorMin rectTf.anchorMax = preRectTf.anchorMax rectTf.anchoredPosition = preRectTf.anchoredPosition rectTf.anchoredPosition3D = preRectTf.anchoredPosition3D toast.gameObject:SetActive(false) SetUI(go.transform) end end function SetUI(uiTF) local title = GetTextMeshProUGUI(uiTF,"BG/Text") --here is where you change the text title.text = "Press F to talk to Gold Angel" end function GetTextMeshProUGUI(tf,path) local ctf = tf:Find(path) if ctf ~= nil then return ctf:GetComponent(typeof(CS.TMPro.TextMeshProUGUI)) end return nil end function FixedUpdate() LookAt() end function LookAt() if mainCamera == nil then mainCamera =UnityEngine.Camera.main end if mainCamera == nil then return end local pos = player.transform.position pos.y = transform.position.y transform:LookAt(pos, Vector3.up) end