Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to pass value of PlayerPrefs from c# to Js??

Discussion in 'Scripting' started by djoshi, Jul 11, 2014.

  1. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    Hi,

    I have plugin for IAP which is in c# & my game is in JS.

    So how would I use SetInt in c# & do GetInt inside JS??

    so that game can stores IAP data. I think it is using SendMessage but how exactly?
     
  2. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    PlayerPrefs are used the same regardless of the language.
     
  3. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    By saying "used the same" you mean both can directly interact? if I do PlayerPrefs.SetInt("xyz",1) in c# & PlayerPrefs.GetInt("xyz") in JS. This will work?
     
  4. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
  5. taxvi

    taxvi

    Joined:
    Feb 18, 2013
    Posts:
    30
    dude, Java is tiny bit different from JavaScript, so the thread title is a little misleading, please change it ^_^
     
  6. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,739
    the syntax for something so basic is the same between, unity JavaScript and C# so that code will work in both.

    Also heads up Java and Unity's JavaScript are completely different and unrelated languages.