示例#1
0
 void Start()
 {
     if (PlayerPrefs.HasKey("Input Directory"))
     {
         inputDirectory = PlayerPrefs.GetString("Input Directory");
     }
     if (PlayerPrefs.HasKey("Output Directory"))
     {
         outputDirectory = PlayerPrefs.GetString("Output Directory");
     }
     if (PlayerPrefs.HasKey("Conversion Mode"))
     {
         conversionMode = (ConversionModes)PlayerPrefs.GetInt("Conversion Mode");
     }
 }
示例#2
0
    private void Start()
    {
        if (PlayerPrefs.HasKey("Input Directory"))
        {
            InputDirectory = PlayerPrefs.GetString("Input Directory");
        }

        if (PlayerPrefs.HasKey("Output Directory"))
        {
            OutputDirectory = PlayerPrefs.GetString("Output Directory");
        }

        if (PlayerPrefs.HasKey("Conversion Mode"))
        {
            ConversionMode = (ConversionModes)PlayerPrefs.GetInt("Conversion Mode");
        }

        var newGameObject = new GameObject();

        newGameObject.transform.localScale = new Vector3(-1.0f, 1.0f, 1.0f);
        _meshFilter = newGameObject.AddComponent <MeshFilter>();
        newGameObject.AddComponent <MeshRenderer>().material = BrickMaterial;
    }
示例#3
0
    private void OnGUI()
    {
        switch (_state)
        {
        case State.Start:
            GUI.Box(new Rect(10, 10, 250, 250), "");

            GUI.Label(new Rect(15, 10, 240, 25), "Input directory:");
            InputDirectory = GUI.TextField(new Rect(15, 30, 240, 25), InputDirectory, 100);

            GUI.Label(new Rect(15, 60, 240, 25), "Output directory:");
            OutputDirectory = GUI.TextField(new Rect(15, 80, 240, 25), OutputDirectory, 100);

            GUI.Label(new Rect(15, 110, 240, 25), "Conversion mode:");
            var conversionModeOptions = new[] { " Default", " No UVs", " No UVs, no groups" };
            ConversionMode = (ConversionModes)GUI.SelectionGrid(new Rect(15, 130, 240, 62), (int)ConversionMode,
                                                                conversionModeOptions, 1, "toggle");

            //Toggle between convening to G or OBJ
            if (GUI.Button(new Rect(15, 200, 240, 25), ToG ? "Converting To G" : "Converting To OBJ"))
            {
                ToG = !ToG;
            }

            if (GUI.Button(new Rect(15, 230, 240, 25), "Go"))
            {
                if (!Directory.Exists(InputDirectory))
                {
                    InputDirectory = "Directory doesn't exist";
                    break;
                }

                _inputFiles = Directory.GetFiles(InputDirectory, ToG ? "*.obj" : "*.g",
                                                 SearchOption.AllDirectories);
                //Debug.Log(inputFiles.Length + " bricks");
                if (!_inputFiles.Any())
                {
                    InputDirectory = $"No {(ToG ? "*.obj" : "*.g")} files found";
                    break;
                }

                if (!Directory.Exists(OutputDirectory))
                {
                    Directory.CreateDirectory(OutputDirectory);
                }

                PlayerPrefs.SetString("Input Directory", InputDirectory);
                PlayerPrefs.SetString("Output Directory", OutputDirectory);
                PlayerPrefs.SetInt("Conversion Mode", (int)ConversionMode);
                _garbageCounter            = 0;
                QualitySettings.vSyncCount =
                    0;     // disable vsync while converting so we don't limit conversion speed to framerate
                _startTime = DateTime.Now;
                _state     = State.Converting;
            }

            break;

        case State.Converting:
            GUI.Box(new Rect(10, 10, 250, 70), "");
            GUI.Label(new Rect(15, 10, 240, 25),
                      string.Format("Converted brick {0} ({1} of {2})", _brickId, _currentFile, _inputFiles.Length));
            GUI.Label(new Rect(15, 30, 240, 25),
                      string.Format("Time: {0:D2}:{1:D2}", _timeSpan.Minutes, _timeSpan.Seconds));

            var nextBrickId = Path.GetFileNameWithoutExtension(_inputFiles[_currentFile] + 1);
            GUI.Label(new Rect(15, 50, 240, 25), string.Format("Now converting brick {0}...", nextBrickId));
            break;

        case State.Done:
            GUI.Box(new Rect(10, 10, 250, 70), "");
            GUI.Label(new Rect(15, 10, 240, 25),
                      string.Format("Converted brick {0} ({1} of {2})", _brickId, _currentFile, _inputFiles.Length));
            GUI.Label(new Rect(15, 30, 240, 25),
                      string.Format("Time: {0:D2}:{1:D2}", _timeSpan.Minutes, _timeSpan.Seconds));

            if (GUI.Button(new Rect(15, 50, 240, 25), "Back"))
            {
                SceneManager.LoadScene("Scene");
            }

            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
示例#4
0
    void OnGUI()
    {
        switch (state)
        {
        case State.Start:
            GUI.Box(new Rect(10, 10, 250, 220), "");

            GUI.Label(new Rect(15, 10, 240, 25), "Input directory:");
            inputDirectory = GUI.TextField(new Rect(15, 30, 240, 25), inputDirectory, 100);

            GUI.Label(new Rect(15, 60, 240, 25), "Output directory:");
            outputDirectory = GUI.TextField(new Rect(15, 80, 240, 25), outputDirectory, 100);

            GUI.Label(new Rect(15, 110, 240, 25), "Conversion mode:");
            string[] conversionModeOptions = new string[] { " Default", " No UVs", " No UVs, no groups" };
            conversionMode = (ConversionModes)GUI.SelectionGrid(new Rect(15, 130, 240, 62), (int)conversionMode, conversionModeOptions, 1, "toggle");

            if (GUI.Button(new Rect(15, 200, 240, 25), "Go"))
            {
                if (!Directory.Exists(inputDirectory))
                {
                    inputDirectory = "Directory doesn't exist";
                    break;
                }
                inputFiles = Directory.GetFiles(inputDirectory, "*.g");
                //Debug.Log(inputFiles.Length + " bricks");
                if (inputFiles.Length == 0)
                {
                    inputDirectory = "No .g files found";
                    break;
                }
                if (!Directory.Exists(outputDirectory))
                {
                    Directory.CreateDirectory(outputDirectory);
                }
                PlayerPrefs.SetString("Input Directory", inputDirectory);
                PlayerPrefs.SetString("Output Directory", outputDirectory);
                PlayerPrefs.SetInt("Conversion Mode", (int)conversionMode);
                garbageCounter             = 0;
                QualitySettings.vSyncCount = 0;                         // disable vsync while converting so we don't limit conversion speed to framerate
                startTime = DateTime.Now;
                state     = State.Converting;
            }
            break;

        case State.Converting:
            GUI.Box(new Rect(10, 10, 250, 70), "");
            GUI.Label(new Rect(15, 10, 240, 25), string.Format("Converted brick {0} ({1} of {2})", brickID, currentFile, inputFiles.Length));
            GUI.Label(new Rect(15, 30, 240, 25), string.Format("Time: {0:D2}:{1:D2}", timeSpan.Minutes, timeSpan.Seconds));

            string nextBrickID = Path.GetFileNameWithoutExtension(inputFiles[currentFile] + 1);
            GUI.Label(new Rect(15, 50, 240, 25), string.Format("Now converting brick {0}...", nextBrickID));
            break;

        case State.Done:
            GUI.Box(new Rect(10, 10, 250, 70), "");
            GUI.Label(new Rect(15, 10, 240, 25), string.Format("Converted brick {0} ({1} of {2})", brickID, currentFile, inputFiles.Length));
            GUI.Label(new Rect(15, 30, 240, 25), string.Format("Time: {0:D2}:{1:D2}", timeSpan.Minutes, timeSpan.Seconds));

            if (GUI.Button(new Rect(15, 50, 240, 25), "Back"))
            {
                SceneManager.LoadScene("Scene");
            }
            break;
        }
    }