Search Unity

found doc bug

Discussion in 'Documentation' started by rakkarage, Apr 16, 2016.

  1. rakkarage

    rakkarage

    Joined:
    Feb 3, 2014
    Posts:
    683
    http://docs.unity3d.com/ScriptReference/JsonUtility.FromJsonOverwrite.html

    this void function is returning another void function?

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class PlayerState : MonoBehaviour
    4. {
    5.     public string playerName;
    6.     public int lives;
    7.     public float health;
    8.  
    9.     public void Load(string savedData)
    10.     {
    11.         return JsonUtility.FromJsonOverwrite(savedData, this);
    12.     }
    13.  
    14.     // Given JSON input:
    15.     // {"lives":3, "health":0.8}
    16.     // the Load function will change the object on which it is called such that
    17.     // lives == 3 and health == 0.8
    18.     // the 'playerName' field will be left unchanged
    19.  
    20. }
    thanks
     
  2. Shredsauce

    Shredsauce

    Joined:
    Apr 4, 2016
    Posts:
    23
    It makes sense until you try it out. The thing doesn't compile. It looks like whoever wrote the example didn't bother to test it out. Probably due to the hassle of having to come up with a dummy string for saveData.
     
  3. Alex_May

    Alex_May

    Joined:
    Dec 29, 2013
    Posts:
    158
    Yes, the return keyword is not only superfluous but erroneous. I'll log it. Thanks for the report!
     
    rakkarage likes this.
unityunity