Esempio n. 1
0
    private void DrawFileSelector()
    {
        Rect   box      = new Rect(5, 5, EditorRect.width - 10, 48);
        float  boxWidth = box.width - 20;
        string tempPath = fPath;

        DrawRect(new Rect(0, 0, EditorRect.width, 15), new Color(.6f, .6f, .6f));

        GUI.skin.label.fontSize      = 8;
        GUI.skin.button.fontSize     = 8;
        EditorStyles.popup.fontSize  = 8;
        GUI.skin.textField.alignment = TextAnchor.MiddleLeft;

        GUI.Label(new Rect(5, 0, 100, 15), "Binary Bitmap File");
        GUI.BeginGroup(new Rect(5, 15, box.width, 150));

        fPath = EditorGUI.TextField(new Rect(10, 8, boxWidth - 55, 20), fPath);

        if (GUI.Button(new Rect(boxWidth - 45, 8, 60, 20), new GUIContent("File", "Choose a file to view")))
        {
            fPath = EditorUtility.OpenFilePanel("Choose a file to view", fPath, "");

            if (File.Exists(fPath))
            {
                if (CheckFileType(fPath))
                {
                    fTexture = BinaryData.Loader(fPath);
                    show     = true;
                }
                else
                {
                    EditorUtility.DisplayDialog("The File Format is not correct", "Please choose a different Format\n ( bin, lab, dat )", "Next");
                    fPath = tempPath;
                    return;
                }
            }
        }
        if (fPath == "" && tempPath != "")
        {
            fPath = tempPath;
        }

        GUI.EndGroup();
    }