Je cherche a faire un script Player qui va contenir toutes ses infos, comme les stats par exemple. Mais j'ai besoin que ce script soit accessible depuis toutes les scènes. Donc j'ai fait en sorte qu'il soit de base static pour éviter qu'il soit présent sur chaque scènes. Bon ensuite la où ça coince, donc maintenant le but c'est que ce script soit sauvegardable...
Le Script :
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public static class Player {
public static bool sfx = true;
public static bool music = true;
static List<Click> clicks = new List<Click> ();
public static int equippedClick;
public static void Actualise () {
if (File.Exists (Application.persistentDataPath + "/Saves." + "Player"))
this = (Player)SaveManager.Load ("Player");
}
public static void Save () {
SaveManager.Save (this, "Player");
}
public static Click EquippedClick () {
return clicks [equippedClick];
}
}
Assets/Scripts/Player.cs(16,11): error CS0716: Cannot convert to static type `Player'
Assets/Scripts/Player.cs(16,4): error CS0026: Keyword `this' is not valid in a static property, static method, or static field initializer
Assets/Scripts/Player.cs(16,4): error CS1604: Cannot assign to `this' because it is read-only
et enfin
Assets/Scripts/Player.cs(20,21): error CS0026: Keyword `this' is not valid in a static property, static method, or static field initializer
Donc la je bloque quoi...
Si vous avez une idée ou une info je suis preneur