//----------------------------------------------------------------------------------------------------

    void Awake()
    {
        // there can be only one!

        if (Singleton != null && Singleton != this)
        {
            Destroy(this.gameObject);
            return;
        }

        // and always one

        DontDestroyOnLoad(transform.gameObject);
        Singleton = this;

        // keep game running when editor does not have focus - needed as we need to dispatch on the game thread (which would be paused otherwise)

        if (RunInBackground)
        {
            Application.runInBackground = true;
        }

        var root = Path.Combine(Application.streamingAssetsPath, StaticFiles != null ? StaticFiles : "");

        HandlerFile.Mount("persistent", Application.persistentDataPath);
        HandlerFile.Mount("streaming", Application.streamingAssetsPath);
        HandlerFile.Mount("root", root);


        Application.logMessageReceivedThreaded += HandlerUtils.LogMessage;
        Events.Singleton.BindEvents();
    }
Exemple #2
0
        public void save <T>(T obj)
        {
            DataContractJsonSerializer contract = new DataContractJsonSerializer(typeof(T));

            var obj_json = JsonConvert.ConvertToJson(obj, contract);

            HandlerFile.WriteLine(obj_json, FILE_NAME);

            Console.WriteLine("Created: " + obj_json);
        }
Exemple #3
0
        public User findByLoginAndPassword(String login, String password)
        {
            User user = new User();

            foreach (String line in HandlerFile.RaedLine(FILE_NAME))
            {
                user = JsonConvert.ConvertToObject(user, line) as User;

                if (user.IsUser(login, password, user))
                {
                    Console.WriteLine("Find user: "******" - " + user.email);
                    return(user);
                }
            }
            Console.WriteLine("User not found");
            return(null);
        }