示例#1
0
 /// <summary>
 /// Loads on enable
 /// </summary>
 private void OnEnable()
 {
     if (String.IsNullOrEmpty(m_exportFolder))
     {
         m_exportFolder = GaiaDirectories.GetScannerExportDirectory();
     }
     SetOrCreateMeshComponents();
 }
示例#2
0
 /// <summary>
 /// Reset the scanner
 /// </summary>
 public void ResetData()
 {
     m_exportFolder          = GaiaDirectories.GetScannerExportDirectory();
     m_exportFileName        = "/Scan " + string.Format("{0:YYYYMMDD-hhmmss}", DateTime.Now);
     m_boundsSet             = false;
     m_scanBounds            = new Bounds(GetPosition(gameObject, null), Vector3.one * 10f);
     m_scanWidth             = m_scanDepth = m_scanHeight = 0;
     m_baseLevel             = 0f;
     transform.localRotation = Quaternion.identity;
     transform.localScale    = Vector3.one;
 }
示例#3
0
        private void GlobalPanel(bool helpEnabled)
        {
            //Text intro
            GUILayout.BeginVertical("Gaia Scanner", m_boxStyle);
            GUILayout.Space(20);
            EditorGUILayout.LabelField("The Gaia Scanner allows you to create new stamps from Windows R16, Windows 16 bit RAW, Mac 16 bit RAW, Terrains, Textures or Meshes. Just drag and drop the file or object onto the area below to scan it.", m_wrapStyle);
            GUILayout.EndVertical();

            DropAreaGUI();

            bool originalGUIState = GUI.enabled;

            if (!m_scanner.m_objectScanned)
            {
                GUI.enabled = false;
            }

            //DrawDefaultInspector();
            GUILayout.BeginVertical("Setup", m_boxStyle);
            GUILayout.Space(20);
            m_editorUtils.Heading("GlobalSettings");
            m_scanner.m_previewMaterial = (Material)m_editorUtils.ObjectField("PreviewMaterial", m_scanner.m_previewMaterial, typeof(Material), false, helpEnabled);
            EditorGUILayout.BeginHorizontal();
            m_scanner.m_exportFolder = m_editorUtils.TextField("ExportPath", m_scanner.m_exportFolder);

            if (m_editorUtils.Button("ExportDirectoryOpen", GUILayout.Width(80)))
            {
                string path = EditorUtility.SaveFolderPanel(m_editorUtils.GetTextValue("ExportDirectoryWindowTitle"), GaiaDirectories.GetUserStampDirectory(), GaiaDirectories.SCANNER_EXPORT_DIRECTORY.Replace("/", ""));
                if (path.Contains(Application.dataPath))
                {
                    m_scanner.m_exportFolder = GaiaDirectories.GetPathStartingAtAssetsFolder(path);
                }
                else
                {
                    EditorUtility.DisplayDialog("Path outside the Assets folder", "The selected path needs to be inside the Assets folder of the project. Please select an appropiate path.", "OK");
                    m_scanner.m_exportFolder = GaiaDirectories.GetScannerExportDirectory();
                }
            }
            EditorGUILayout.EndHorizontal();
            m_editorUtils.InlineHelp("ExportPath", helpEnabled);
            m_scanner.m_exportFileName = m_editorUtils.TextField("ExportFilename", m_scanner.m_exportFileName, helpEnabled);

            float oldBaseLevel = m_scanner.m_baseLevel;

            m_scanner.m_baseLevel = m_editorUtils.Slider("BaseLevel", m_scanner.m_baseLevel, 0f, 1f, helpEnabled);
            if (oldBaseLevel != m_scanner.m_baseLevel)
            {
                SceneView.lastActiveSceneView.Repaint();
            }
            EditorGUILayout.Space(10f);
            m_editorUtils.Heading("ObjectTypeSettings");
            if (m_scanner.m_scannerObjectType == ScannerObjectType.Mesh)
            {
                m_scanner.m_scanResolution = m_editorUtils.Slider("ScanResolution", m_scanner.m_scanResolution, 0.0001f, 1f, helpEnabled);
                if (m_scanner.m_lastScanResolution != m_scanner.m_scanResolution)
                {
                    if (m_editorUtils.Button("RefreshScan"))
                    {
                        m_scanner.LoadGameObject(m_scanner.m_lastScannedMesh);
                    }
                }
            }
            if (m_scanner.m_scannerObjectType == ScannerObjectType.Raw)
            {
                //Drop Options section
                GUILayout.BeginHorizontal();
                {
                    EditorGUILayout.PrefixLabel(BYTE_ORDER_LABEL);
                    EditorGUI.BeginChangeCheck();
                    {
                        m_rawByteOrder = (GaiaConstants.RawByteOrder)GUILayout.Toolbar((int)m_rawByteOrder, new string[] { "IBM PC", "Macintosh" });
                    }
                    if (EditorGUI.EndChangeCheck())
                    {
                        ReloadRawFile();
                    }
                }
                GUILayout.EndHorizontal();
                m_editorUtils.InlineHelp("RawFileByteOrder", helpEnabled);

                EditorGUI.BeginChangeCheck();
                {
                    m_rawBitDepth = (GaiaConstants.RawBitDepth)EditorGUILayout.Popup(BIT_DEPTH_LABEL, (int)m_rawBitDepth, BIT_DEPTHS_LABELS);
                    m_editorUtils.InlineHelp("RawFileBitDepth", helpEnabled);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    ReloadRawFile();
                }
                GUILayout.BeginVertical();
                if (m_showRawInfo)
                {
                    EditorGUILayout.HelpBox("Assumed " + (m_rawBitDepth == GaiaConstants.RawBitDepth.Sixteen ? "16-bit" : "8-bit") + " RAW " + m_assumedRawRes + " x " + m_assumedRawRes, MessageType.Info);
                }
                if (m_showBitDepthWarning)
                {
                    EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("8BitWarning"), MessageType.Warning);
                }
                GUILayout.EndVertical();
            }
            EditorGUILayout.Space(10f);



            m_editorUtils.Heading("ExportSettings");
            //m_scanner.m_textureExportResolution = (GaiaConstants.GaiaProWaterReflectionsQuality) EditorGUILayout.EnumPopup(new GUIContent("Export Resolution", "Sets the export resolution of the texture generated"), m_scanner.m_textureExportResolution);
            m_scanner.m_normalize         = m_editorUtils.Toggle("Normalize", m_scanner.m_normalize, helpEnabled);
            m_scanner.m_exportTextureAlso = m_editorUtils.Toggle("ExportPNG", m_scanner.m_exportTextureAlso, helpEnabled);
            //m_scanner.m_exportBytesData = m_editorUtils.Toggle("ExportBytesData", m_scanner.m_exportBytesData, helpEnabled);

            GUILayout.EndVertical();

            //Terraform section
            GUILayout.BeginVertical("Scanner Controller", m_boxStyle);
            GUILayout.Space(20);
            if (!string.IsNullOrEmpty(m_infoMessage))
            {
                EditorGUILayout.HelpBox(m_infoMessage, MessageType.Info);
            }
            if (m_scanner.m_scanMap == null)
            {
                EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("NoScanDataInfo"), MessageType.Info);
                GUI.enabled = false;
            }
            GUILayout.BeginHorizontal();
            Color normalBGColor = GUI.backgroundColor;

            if (m_settings == null)
            {
                m_settings = GaiaUtils.GetGaiaSettings();
            }

            GUI.backgroundColor = m_settings.GetActionButtonColor();
            if (m_editorUtils.Button("SaveScan"))
            {
                string path = m_scanner.SaveScan();
                AssetDatabase.Refresh();
                path += ".exr";
                Object exportedTexture = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                if (exportedTexture != null)
                {
                    m_infoMessage = "Scan exported to: " + path;
                    Debug.Log(m_infoMessage);
                    EditorGUIUtility.PingObject(exportedTexture);
                }
            }
            GUI.backgroundColor = normalBGColor;
            GUI.enabled         = true;
            if (m_editorUtils.Button("Clear"))
            {
                m_scanner.Clear();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            GUILayout.EndVertical();
            GUILayout.Space(5f);

            m_showRawInfo         = m_assumedRawRes > 0;
            m_showBitDepthWarning = m_rawBitDepth == GaiaConstants.RawBitDepth.Eight;

            GUI.enabled = originalGUIState;
        }