Author Topic: UIInput PlayerPrefs NGUI  (Read 2064 times)

wohltaeter

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
UIInput PlayerPrefs NGUI
« on: February 21, 2017, 05:33:38 AM »
Hi,

I have a problem with UIInput.  I used it to save the player name and "saved as" Player_Eins in PlayerPrefs. - No I want to use several Profiles which I load in and then I want to use Player_Eins as the actual player. The actual player I set in Player_Prefs via code. But some "Ngui Ghost" is setting it back to an old value. - Can you please help me to delete this old value? And set it via code (PlayerPrefs to another Name I load). - It comming back every Awake.
I tried also to reset the starting value in UIInput and also changed Saved As to Player2. But Player_Prefs Player_Eins is again set back to an old value.

Thanks,
wohl

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput PlayerPrefs NGUI
« Reply #1 on: February 21, 2017, 12:50:33 PM »
You need to do it before the UIInput's Start() function gets called, such as in Awake().
  1. using UnityEngine;
  2.  
  3. [RequireComponent(typeof(UIInput))]
  4. public class ChangeSavedAs : MonoBehaviour
  5. {
  6.     public string prefix;
  7.  
  8.     void Awake ()
  9.     {
  10.         var input = GetComponent<UIInput>();
  11.         input.saveAs = prefix + input.saveAs;
  12.     }
  13. }

wohltaeter

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIInput PlayerPrefs NGUI
« Reply #2 on: February 23, 2017, 07:57:17 AM »
thx! :)