示例#1
0
    void OnMouseDown()
    {
        if (Input.GetKey(KeyCode.LeftShift))
        {
            var loadContext = LoadContext.FromUnbufferedFile(FileName);
            if (loadContext.Exists(Category))
            {
                PointsComponent.Points = loadContext.Load <int>(Category);
            }
            else
            {
                PointsComponent.Points = 0;
            }
        }
        else
        {
            var saveContext = SaveContext.ToUnbufferedFile(FileName);
            saveContext.Save(PointsComponent.Points, Category);

            /*
             * This is not needed when using unbuffered files:
             *
             * saveContext.Flush();
             */
        }
    }