Пример #1
0
    void OnGUI()
    {
        GenericMenu menu = new GenericMenu();

        _sourceTerrain = (Terrain)EditorGUILayout.ObjectField("Select Terrain", _sourceTerrain, typeof(Terrain), true);
        GUILayout.Space(10);

        //提供导出按钮
        if (_sourceTerrain != null)
        {
            GUILayout.Label("Save Directory: Assets" + DIRECTORYNAME + "/" + _directoryName + "/");
            GUILayout.Space(10);

            _directoryName = GUILayout.TextField(_directoryName);

            //图片导出分辨率
            _resolution = (RESOLUTIONS)EditorGUILayout.EnumPopup("Base Map Resolution", _resolution);

            GUILayout.Space(10);

            //导出主贴图按钮
            if (GUILayout.Button("Export Base Map"))
            {
                ExportBasemap();
            }
            GUILayout.Space(10);

            //导出BlendMap & IndexMap按钮
            if (GUILayout.Button("Export Index And Blend Map"))
            {
                ExportIndexAndWeightMap();
                //ExportIndexAndBlendMap();
            }
        }
        else
        {
            GUILayout.Label("Please select a terrain!");
        }
    }
Пример #2
0
    private static void setNewGameWindow()
    {
        // get width and height from user
        resolution = (RESOLUTIONS)EditorGUILayout.EnumPopup("Resolution", resolution);
        switch (resolution)
        {
        case RESOLUTIONS._480_x_320: { mobileRes.x = 480; mobileRes.y = 320; break; }

        case RESOLUTIONS._800_x_480: { mobileRes.x = 800; mobileRes.y = 480; break; }

        case RESOLUTIONS._854_x_480: { mobileRes.x = 854; mobileRes.y = 480; break; }

        case RESOLUTIONS._1024_x_600: { mobileRes.x = 1024; mobileRes.y = 600; break; }

        case RESOLUTIONS._1280_x_800: { mobileRes.x = 1280; mobileRes.y = 800; break; }

        default: break;
        }

        // get mobile ppi
        mobilePPI = EditorGUILayout.IntField("Mobile PPI", mobilePPI);

        // get monitor's horizontal inches from user
        monitorInchX = EditorGUILayout.FloatField("Monitor Inches X", monitorInchX);

        applyScaleFactor = EditorGUILayout.Toggle("Apply Scale Factor to World Objects", applyScaleFactor);

        // wait for user press button
        bool pressed = GUILayout.Button("Set");

        if (!pressed)
        {
            return;
        }

        // mobile device horizontal inches
        Vector2 mobileInch;

        mobileInch.x = mobileRes.x / mobilePPI;

        // mobile resolution trasnformed to our monitor's resolution
        Vector2 mobileOnMonitorRes = new Vector2(mobileRes.x, mobileRes.y);

        if (applyScaleFactor)
        {
            mobileOnMonitorRes.x = (mobileInch.x * Screen.currentResolution.width) / monitorInchX;
            float aspect = mobileRes.y / mobileRes.x;
            mobileOnMonitorRes.y = mobileOnMonitorRes.x * aspect;
            // this factor to be applied in Editor mode only, multiply the scale of your game world by this
            scaleFactor = mobileOnMonitorRes.x / mobileRes.x;
        }

        // get current game window position
        Rect position = GetMainGameView().position;

        // initialize window-specific title data and such (this is cached)
        if (gameWindow == null)
        {
            gameWindow = new WindowInfos();
        }
        gameWindow.game.isOpen   = false;                                                                                         //workaround for setting free aspect ratio
        gameWindow.game.position = new Rect(position.x, position.y - 5, mobileOnMonitorRes.x, mobileOnMonitorRes.y + menuOffset); // left,top,width,height

        // apply the scale factor? so every object looks like it was in mobile ppi
        if (applyScaleFactor)
        {
            scaleFactor = scaleFactor * 1f;
            // aplicar escala en XY a game objects y desplazar la main camera en XY por mismo factor
        }

        // close the popup window
        if (popup != null)
        {
            popup.Close();
        }
    }
Пример #3
0
    void OnGUI()
    {
        GenericMenu menu = new GenericMenu();

        _sourceTerrain = (Terrain)EditorGUILayout.ObjectField("Select Terrain", _sourceTerrain, typeof(Terrain), true);
        GUILayout.Space(10);

        //提供导出按钮
        if (_sourceTerrain != null)
        {
            GUILayout.Label("Save Directory: Assets" + DIRECTORYNAME + "/" + _directoryName + "/");
            GUILayout.Space(10);

            _directoryName = GUILayout.TextField(_directoryName);

            //图片导出分辨率
            _resolution = (RESOLUTIONS)EditorGUILayout.EnumPopup("Base Map Resolution", _resolution);

            GUILayout.Space(10);

            //导出主贴图按钮
            if (GUILayout.Button("Export Base Map"))
            {
                ExportBasemap();
                ExportIndexAndWeightMap();
            }

            //重新导入主贴图按钮
            if (GUILayout.Button("Reimport Base Map"))
            {
                ReimportBasemap();
                ReimportIndexAndWeightMap();
            }

            /*GUILayout.Space(10);
             *
             * //导出BlendMap & IndexMap按钮
             * if (GUILayout.Button("Export Index And Blend Map"))
             * {
             *  ExportIndexAndWeightMap();
             * }
             *
             * //重新导入Blend & Index Map
             * //需要有这两张图
             * if (GUILayout.Button("Reimport Index And Blend Map"))
             * {
             *  ReimportIndexAndWeightMap();
             * }*/


            //自动复制Tiling功能部分
            GUILayout.Space(20);
            _targetMaterial = (Material)EditorGUILayout.ObjectField("Select Material", _targetMaterial, typeof(Material), true);
            GUILayout.Space(10);

            if (null != _targetMaterial)
            {
                if (GUILayout.Button("Copy Tiling from Terrian to Material"))
                {
                    CopyTiling();
                }
            }
        }
        else
        {
            GUILayout.Label("Please select a terrain!");
        }
    }