Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

sorry, not a dev, pasting a json into a game has a size limit? what is it?

Discussion in 'General Discussion' started by tsmspace, Oct 27, 2022.

  1. tsmspace

    tsmspace

    Joined:
    Oct 6, 2019
    Posts:
    47
    I'm just a player of a game, but I am using unity to make maps for the game.

    When making these maps, to share them, you create a json file with the position and rotation of the racing gate for each gate in a list. Then, you share a text file which other players can paste into a "map info" field in the custom races menu,,, but there is a size limit. The dev suggested they might change to a "copy from clipboard button" instead of a paste field, but I thought that perhaps the problem was a unity paste buffer, and then the problem would persist.

    I don't know which forum to post this in so I went with general. Thanks if anyone knows the answer! The dev is very busy and it's a free game passion project which is where the dev is learning to gamedev. (it's called Fly Dangerous, it's an outstanding game project and naturally my life depends on it.) ... (also my life depends on having more gates than the custom maps currently support, so I'm hoping that it's an easy solution, but I'm worried that it may be a situation where some particular coding must be done to increase the size of the paste buffer that is normally defaulted and therefore not included anywhere in any scripts)

    thanks again!
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,554
    If there's a limit, and the developer is using UI.InputField, then the limit is set by the developer. By default, character limit is 0, meaning you can dump as much data into it, as C# string would allow, and in C# maximum string size is 2 billion characters.
     
  3. tsmspace

    tsmspace

    Joined:
    Oct 6, 2019
    Posts:
    47
    yes that appears to be the case but I see nowhere that a limit could be set,, they do place the text into a var ,, does that have a size? I will paste the code below


    edit::: I deleted the code, there's nothing there. I also found the input field in unity, and indeed when I click on the object, and look at the inspector, the character limit is set to zero. and yes it's [SerializeField] private InputField saveInput;

    edit 2 ::: I found somewhere that someone posted unity was limiting their characters to 16000. I pasted my json into a char counter and it came up 19763. the one I have that is working is 14361, and that sounds about right. I can't just increase my gates by adding one character, and also, I can't just add one gate at a time because they are in groupings,, so it appears as though this is also my limit.
     
    Last edited: Oct 27, 2022
  4. PizzaPie

    PizzaPie

    Joined:
    Oct 11, 2015
    Posts:
    104
    Ask the dev to allow setting a path in input field pointing to json file and then read it from there rather than copying stuff directly to it.

    Having to copy paste anything big and structured as a json into an input field is bad design.
     
    Socrates likes this.
  5. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    Note that you can "optimize" the size of your Json by removing all whitespace, including newlines. This is still valid Json, and JsonUtility has an option to enable/disable that formatting.
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,645
    Unity does not impose any clipboard limits (I just checked the code). It will take the clipboard data as Windows provides it.
     
    Kirsche and Socrates like this.
  7. tsmspace

    tsmspace

    Joined:
    Oct 6, 2019
    Posts:
    47
    I'm 100% sure that I'm still being capped around 16,000 chars. It's a free game called Fly Dangerous, and a quick download, you can see the window I'm talking about if you want to check it out. All it does when you're over is say "invalid world data" , but when it does that from being too many chars, the last chars that are allowed into the field are what you see, so I can check against the notepad where it is being cut. I can try with the whitespaces but it's a ton of work and honestly shouldn't get me more than a few gates at best. It can matter to have just a few extra for some layouts but the "unlimited size" one would be nicer.
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,645
    I'm not saying the game doesn't do it. The game can do whatever it wants with the data Unity provides. All I'm saying is that Unity is not capping it.
     
    Antypodish likes this.