Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by vverma9 · Apr 13, 2018 at 10:29 PM · arraywwwwwwformindexoutofrangeexception

UnityEngineInternal.WebRequestUtils.MakeInitialUrl throwing IndexOutOfRangeException

I am trying to submit data to a google form from Unity using the tutorial here. I am not sure why I am getting index out of range for some internal method called MakeInitialUrl, even though I am not using any Array. I couldn't even find any documentation regarding this method anywhere. https://stackoverflow.com/questions/49825428/unityengineinternal-webrequestutils-makeinitialurl-throwing-indexoutofrangeexcep

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 /// <summary>
 /// This class handles the in game survey system.
 /// The main menu game object should not be enabled when using this!
 /// </summary>
 public class Survey : MonoBehaviour
 {    
     public Canvas[] screens;
     // Background Info
     public InputField ageInput;
     public Dropdown genderInput;
     public Dropdown schoolInput;
     public InputField gradeInput;
     public Dropdown gamerInput;
     public InputField gameTimeInput;
 
     // String to be sent to Sheets
     private static ArrayList sheets = new ArrayList();
     WWWForm surveyForm;
     
     [SerializeField]
     private string BASE_URL = "https://docs.google.com/forms/d/e/1FAIpQLSfAaFaebUfUc2ywQsXYXgnLptFWqyHawAqAHAy-0XooFMA0Wg/formResponse";
     // Use this for initialization
     void Start()
     {              
         updating = false;
         currentStatus = "Offline";
         surveyForm = new WWWForm();
         changeScreens();
     }
     IEnumerator Post()
     {
         byte[] rawData = surveyForm.data;
         WWW www = new WWW(BASE_URL, rawData);
         yield return www;
     }
     public void hitContinueBackgroundScreen()
     {        
         surveyForm.AddField("entry.193768661", ageInput.text);
         surveyForm.AddField("entry.1322511470", genderInput.value);       
         surveyForm.AddField("entry.2009551840", schoolInput.value);        
         surveyForm.AddField("entry.1682279685", gamerInput.value);
         surveyForm.AddField("entry.309799851", gameTimeInput.text);        
         StartCoroutine(Post());
     }   
 }

IndexOutOfRangeException: Array index is out of range. UnityEngineInternal.WebRequestUtils.MakeInitialUrl (System.String targetUrl, System.String localUrl) (at C:/buildslave/unity/build/Modules/UnityWebRequest/Public/WebRequestUtils.cs:515) UnityEngine.Networking.UnityWebRequest.set_url (System.String value) (at C:/buildslave/unity/build/Modules/UnityWebRequest/Public/UnityWebRequest.bindings.cs:326) UnityEngine.Networking.UnityWebRequest..ctor (System.String url, System.String method) (at C:/buildslave/unity/build/Modules/UnityWebRequest/Public/UnityWebRequest.bindings.cs:138) UnityEngine.WWW..ctor (System.String url, System.Byte[] postData) (at C:/buildslave/unity/build/Modules/UnityWebRequestWWW/Public/WWW.cs:76) Survey+c__Iterator0.MoveNext () (at Assets/Survey/Survey.cs:76) UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) Survey:hitContinueBackgroundScreen() (at Assets/Survey/Survey.cs:146) UnityEngine.EventSystems.EventSystem:Update()

Debug logs returned with following data:

gamerInput.value === 1

gameTimeInput.text === 230

schoolInput.value ===== 6

genderInput.value ==== 3

ageInput.text ==== 22

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Runalotski · Apr 13, 2018 at 11:35 PM

Hi From the stack trace you posted I can see this

UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) Survey:hitContinueBackgroundScreen() (at Assets/Survey/Survey.cs:146)

This is saying that the fault comes from a script called Survey in a function hitContinueBackgroundScreen() which is on line 146.

There is also this log in the stack trace.

Survey+c__Iterator0.MoveNext () (at Assets/Survey/Survey.cs:76)

The stack trace you have posted is read from bottom to top so if we look at the first entry of UnityEngine.EventSystems.EventSystem:Update() this would suggest that eventsystem runs an update function periodically and dies when it hits your survey script. I would imagine this is because your survey script does not initially have the data it is looking for, hence the out of range exception, before the update function runs in eventSystem. I am not too familiar with this so I will need to google, but hopefully this might help you look in the right direction.

The function at the very top of the stack is the last place the error affects and is the most core functionality of the environment which is probably why you cant find information on it. I always try to find references to my own code in stack traces as its most likely to be wrong.

I would do a test to see if you disable your survey script does this error go away, this will at least show that it is in fact an error you can control, Instead of some bug with unity/google.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by vverma9 · Apr 13, 2018 at 11:21 PM

It worked on removing the SerializeField, weird

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by dm_bond · Oct 24, 2018 at 11:06 PM

https://github.com/Unity-Technologies/UnityCsReference/blob/2018.1/Modules/UnityWebRequest/Public/WebRequestUtils.cs#L505 You need to check yourself (!string.IsNullOrEmpty) before pass url to WWW or UnityWebRequest in 2018.1

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

92 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

wwwform send an array the right way! 0 Answers

How to Upload multiple files to a server using UnityWebRequest.Post(); 3 Answers

IndexOutOfRangeException in build but not editor 0 Answers

PUT with WWWform 3 Answers

POST a form over HTTPS with unvalidated SSL Certificate 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges