Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 enderfoxgamingofficial · 2 days ago · componentwebrequestinitialize

Object being created with last info

alright so im creating an object and its being created but theres a problem when its created it works but when i change something in the database i restart the game and it doesnt change i have to restart twice for it to change

this is the code that makes the object

using UnityEngine; using TMPro; using System.Collections; using UnityEngine.Networking; using UnityEngine.UI; using UnityEngine.SceneManagement; using System.Collections.Generic;

public class getInv : MonoBehaviour { [SerializeField] private string getinvEndpoint = "";

 [SerializeField] private string usernamer;
 [SerializeField] private string slot;
 [SerializeField] private string slotnum;
 [SerializeField] private string[] items;

 public GameObject ItemGui;
 public GameObject slot1;
 public GameObject slot2;
 public GameObject slot3;
 public GameObject slot4;
 public GameObject slot5;
 public GameObject slot6;
 public GameObject slot7;
 public GameObject theslot;

 public bool is1;
 public bool is2;
 public bool is3;
 public bool is4;
 public bool is5;
 public bool is6;
 public bool is7;

 public void Start()
 {
     StartCoroutine(TrygetInv());
 }

 public IEnumerator TrygetInv()
 {
     string username = usernamer;

     WWWForm form = new WWWForm();
     form.AddField("rUsername", username);

     UnityWebRequest request = UnityWebRequest.Post(getinvEndpoint, form);
     yield return request.SendWebRequest();

     float startTime = 0.0f;
     while (!request.isDone)
     {
         startTime += Time.deltaTime;

         if (startTime > 10.0f)
         {
             break;
         }

         yield return null;
     }

     if (request.result == UnityWebRequest.Result.Success)
     {
         InventoryResponse response = JsonUtility.FromJson<InventoryResponse>(request.downloadHandler.text);
         Debug.Log(request.downloadHandler.text);
         Debug.Log(response.arraytest);
         string temp = (response.arraytest);
         string[] split;
         string[] seperators = { (":") };

         split = temp.Split(seperators, System.StringSplitOptions.None);
         foreach (var member in split)
         {
             if (member != "")
             {
                 string testing = member;
                 string[] Ending;
                 string[] Keepaways = { ("-") };

                 Ending = testing.Split(Keepaways, System.StringSplitOptions.None);

                 slotnum = Ending[3];
                 Debug.Log(slotnum);

                 Instantiate(ItemGui);
                 ItemSetups iteminfo = ItemGui.GetComponent<ItemSetups>();

                 iteminfo.id = Ending[0];
                 iteminfo.objname = Ending[1];
                 iteminfo.amount = Ending[2];
                 iteminfo.slot = slotnum;
                 iteminfo.slotObj = theslot;
             }
         }
     } else
     {
         Debug.Log("error connecting to inv");
     }

     yield return null;
 }

}

This is the code on the object

using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using UnityEngine.UI;

public class ItemSetups : MonoBehaviour { public Sprite One; public Sprite Two; public string id; public string objname; public string amount; public string slot;

 public GameObject slotObj;

 public TMP_Text Names;
 public TMP_Text Amount;
 public Image Logo;

 public void Update()
 {
     if(id == "1")
     {
         Logo.sprite = One;
     } else if (id == "2")
     {
         Logo.sprite = Two;
     } else
     {
     }
     Names.text = objname;
     Amount.text = amount;
 }

 public void Start()
 {
     gameObject.transform.SetParent(slotObj.transform, false);
 }

}

the console log is said correctly its just the creation that is wrong alt text

unknown.png (11.2 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

137 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 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

Call method on "Start" of a built-in component? 1 Answer

2D Animation does not start 1 Answer

iPhone UI Components? 2 Answers

How to get the first component that implements a specific interface ? 4 Answers

Object reference not set to instance of an object 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