コード例 #1
0
    public void LoadSceneData()
    {
        #if UNITY_EDITOR
        var settingData = TGSettingData.GetInstance();
        var scn         = GameObject.FindObjectOfType <TGBaseScene> ();

        SceneData sceneData = new SceneData();

        if (scn != null)
        {
            sceneData = settingData.GetSceneData(scn);
        }
        else
        {
            sceneData = settingData.sceneDatas[0];
        }

        TGData.SetSceneData(sceneData);

        if (TGData.SceneName != scn.SceneName)
        {
            m_controller.ErrorQuit("当前的场景与game.txt中的设备名称不匹配");
        }
        #else
        var sceneData = LMFileWriter.ReadJSON <SceneData>(TGPaths.SceneData);
        TGData.SetSceneData(sceneData);
        #endif
    }
コード例 #2
0
    public override void ExitScene()
    {
        AudioMng.Instance.StopAll();

        TGData.SaveScore(Score);

        base.ExitScene();
    }
コード例 #3
0
    private void LoadInputConfig()
    {
        bool   testing    = false;
        string deviceName = string.Empty;

        var scn = GameObject.FindObjectOfType <TGBaseScene>();

        deviceName = string.Empty;

        testing    = TGGameConfig.GetValue("测试", 0) == 1;
        deviceName = TGGameConfig.GetValue("训练器材", string.Empty);

        TGData.SetDevice(deviceName, testing);
    }
コード例 #4
0
    public static IEnumerator SaveTexture(Texture2D _tex, string _name)
    {
        float ratio = ( float )_tex.width / _tex.height;
        int   width = 0, height = 0;

        // 如果比例大于阈值,则使用Fix width方案
        // 反之使用Fix Height方案
        if (ratio > FIX_HEIGHT_THRESHOLD)
        {
            width  = FIX_WIDTH;
            height = Mathf.RoundToInt(width / ratio);
        }
        else
        {
            height = FIX_HEIGHT;
            width  = Mathf.RoundToInt(height * ratio);

            // 如果使用Fix Height方案后,宽度还是超标
            // 则再转位Fix Width方案
            if (width > FIX_WIDTH)
            {
                width  = FIX_WIDTH;
                height = Mathf.RoundToInt(width / ratio);
            }
        }

        Debug.Log("Saved Texture Sizes: " + width + ", " + height);

        _tex = TextureScaler.ResizeTexture(_tex, width, height);

        byte[] bytes = _tex.EncodeToPNG();

        string path = TGPaths.FullScreenshotPath(_name);

        Debug.Log("截图路径: " + path);

        // 写入文件
        LMFileWriter.Write(path, bytes);

        // 写到Dicionary里,好之后写入ret.txt
        TGData.SaveScreenshot(_name);

        yield return(null);
    }