C# data saved in playerPrefs with Java menu
Just as messed up as the title sounds. I have a lovely javascript pause menu that i kept because it actually works when I SAVE the player transform and level. Something that C# likes to make a ridiculous pain. the pause menu also has many other functions that work so I do not want to make a C# version. Problem is, I want to add to the SAVE feature other variables of the player that are in C# scripts to PlayerPrefs. Namely the score, health. I am able to do so with key strokes. but that just seems dumb to have to do that in addition to a pause menu. I am trying to convert this save to java so I can then add it to the SAVE functionality in my pause menu. the attached script is how I save and load the players score to PlayerPrefs in C# using keystrokes. I guess I need a javascript that could access this scripts score variable. From that I could add it to my pause menu script. I have spent 2 days studying this online and just get the same errors about "converting a component into int." and others.
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ScoreManager : MonoBehaviour
{
public static int score = 0;
public int MyScore;
public int ReStart;
Text text;
void Awake ()
{
text = GetComponent <Text> ();
}
void Update ()
{
if (Input.GetKeyDown(KeyCode.S))
PlayerPrefs.SetInt ("MyScore",score );
if (Input.GetKeyDown(KeyCode.A))
score = PlayerPrefs.GetInt ("MyScore" );
text.text = "Score: " + score;
}
}
Your answer
Follow this Question
Related Questions
how do i store highscore locally C# (SIMPLE) 3 Answers
PlayerPrefs help ! 1 Answer
how to randomly instantiate prefabs but each with it's own probability? 2 Answers
SetActive dosen't work 0 Answers
Mute Toggle Not Staying On 2 Answers