#Web request- visual scripting

1 messages · Page 1 of 1 (latest)

low verge
#

hi- is there any one knows about web request visual scripting- this is my first part of script and I should see my backend messages in the console . but I can not see-

#

Web request- visual scripting

ember arch
#

Heyoh!
I am not very proficient with Visual Scripting, but I think you need to use the GetDownloadHandler AFTER you sent the request.

low verge
muted berry
#

tbh if you are doing web requests and understand those just write normal code

serene viper
#

I have not worked with "web requests" yet - so i cant be much of a help in this topic.

Tell me - What does it do? "see my backend messages " ---> what is the message you are trying to see in console?

maybe this answer can help with the answer.

serene viper
#

First thing is first: is that button being triggered when you click on it?

with graph open, and play mode ON... click the button, and then the graph node "On Pointer Enter" should turn bluish - confirming that event is fired. Once you have that WORKING, then you move to the next nodes.

let us know.

#

here's an example. how graph looks like when the node is flowing. make sure this one changes color when you trigger it as well

#

Because I suspect it is not working, because you are using a "game object find" by name string... and this is not an efficient way of getting button events

low verge
low verge
low verge
low verge
muted berry
#

Some platforms need il2cpp but that doesn't change c# support

low verge
muted berry
#

No idea what that is and I have no idea how you plan to make this work

low verge
serene viper
#

If you want pure c#, then that c# has to be converted into visual scripting. if you paste the code here maybe we can translate it into uVS

#

But I'm wondering... why do you want to make changes in the scene via a web URL and not within unity?

also - what makes you think if c# won't work - visual scripting will work?

low verge
# serene viper If you want pure c#, then that c# has to be converted into visual scripting. if ...

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class WindowVisibilityManager : MonoBehaviour
{
public GameObject firstStory;
public GameObject secondStory;
public GameObject thirdStory;
public GameObject fourthStory;

private string apiUrl = " ......";

void Start()
{
    // All window objects are set to inactive (hidden) in the Unity Editor before build.
    // No need to hide them by code; they start hidden.

    StartCoroutine(PollBackend());
}

IEnumerator PollBackend()
{
    while (true)
    {
        UnityWebRequest request = UnityWebRequest.Get(apiUrl);
        yield return request.SendWebRequest();

        if (request.result == UnityWebRequest.Result.Success)
        {
            var json = request.downloadHandler.text;
            var dict = JsonUtility.FromJson<WindowVisibilityDict>(json);

            if (dict._1stStoryWindows) firstStory.SetActive(true);
            ....
        }
        else
        {
            Debug.LogError("Backend not reachable: " + request.error);
        }

        yield return new WaitForSeconds(2f); // Poll every 2 seconds
    }
}

}

// Helper class for JSON parsing (adjust field names if necessary)
[System.Serializable]
public class WindowVisibilityDict
{
public bool _1stStoryWindows;
....
}

low verge
low verge
#

@serene viper this is the overal logic :"The window GameObjects are set as inactive (hidden) in the Unity Editor before building and uploading to the metaverse. The Unity Visual Scripting logic periodically contacts the backend server (every some seconds)to check which windows should be revealed. As soon as the backend returns true for a window (such as "1stStoryWindows": true), the script or visual script will set that GameObject to active (visible) in the scene."

serene viper
#

Checking.

serene viper
#

Here's the graph that makes it work. Make sure coroutine is set ON in the triggered event that runs this.

low verge
# serene viper

Thank you so much the first part which is fetching data is working perfectly -then we have json parsing node(similar) to force the object...

serene viper
#

Err hmm