Esempio n. 1
0
        public static int SelectionGridImageAndText(int selected, Texture[] textures, int size, string emptyString)
        {
            GUIStyle style = new GUIStyle("GridListText");

            GUIContent[] contents = new GUIContent[textures.Length];
            for (int i = 0; i < textures.Length; i++)
            {
                contents[i] = new GUIContent(textures[i].name, textures[i]);
            }
            GUILayout.BeginHorizontal("OL Box", GUILayout.MinHeight(50f));
            GUILayout.Space(2);
            GUILayout.BeginVertical();
            GUILayout.Space(2);
            if (textures.Length != 0)
            {
                float numH       = (Screen.width - 20) / size;
                int   numV       = (int)Mathf.Ceil(textures.Length / numH);
                Rect  aspectRect = GUILayoutUtility.GetAspectRect(numH / numV);
                style.alignment = TextAnchor.MiddleCenter;
                selected        = GUI.SelectionGrid(aspectRect, selected, contents, (Screen.width - 20) / size, style);
            }
            else
            {
                GUILayout.Label(emptyString, GUILayout.MinHeight(50f));
            }
            GUILayout.EndVertical();
            GUILayout.Space(2);
            GUILayout.EndHorizontal();
            return(selected);
        }
Esempio n. 2
0
    private static Block SelectionGrid(BlockSet blockSet, Block selected)
    {
        int xCount = Mathf.FloorToInt(Screen.width / 66f);
        int yCount = Mathf.CeilToInt((float)blockSet.Blocks.Count / xCount);

        Rect  rect        = GUILayoutUtility.GetAspectRect((float)xCount / yCount);
        float labelHeight = GUI.skin.label.CalcHeight(GUIContent.none, 0);

        GUILayout.Space(labelHeight * yCount);
        rect.height += labelHeight * yCount;

        Rect[] rects = GUIUtils.Separate(rect, xCount, yCount);
        int    i     = 0;

        foreach (Block block in blockSet.Blocks)
        {
            Rect position = rects[i];
            position.xMin += 2;
            position.yMin += 2;

            bool isSelected = DrawItem(position, block, selected == block, i);
            if (isSelected)
            {
                selected = block;
            }

            i++;
        }

        return(selected);
    }
Esempio n. 3
0
    /**
     * DrawCubeFacesEditor is a helper method for DrawCubeBlockEditor (for drawing faces specifically)
     */
    private static CubeFace DrawCubeFacesEditor(CubeFace face, Cube cube, Atlas atlas)
    {
        string[] items = new string[6];
        for (int i = 0; i < 6; i++)
        {
            items[i] = ((CubeFace)i).ToString();
        }
        Texture texture = atlas.GetMaterial().mainTexture;

        GUILayout.BeginVertical("box");
        face = (CubeFace)GUILayout.Toolbar((int)face, items);
        Rect bigRect = GUILayoutUtility.GetAspectRect(items.Length);

        for (int i = 0; i < items.Length; i++)
        {
            Rect position = bigRect;
            position.width /= items.Length;
            position.x     += i * position.width;
            Rect face_rect = cube.GetFace((CubeFace)i);
            GUI.DrawTextureWithTexCoords(position, texture, face_rect);
        }
        GUILayout.EndVertical();

        return(face);
    }
Esempio n. 4
0
        public static void DrawTexture(Texture2D texture)
        {
            var ratio = (float)texture.width / (float)texture.height;
            var rect  = GUILayoutUtility.GetAspectRect(ratio, GUILayout.ExpandWidth(true));

            GUI.DrawTexture(rect, texture, ScaleMode.ScaleAndCrop);
        }
Esempio n. 5
0
        public static int AspectSelectionGrid(int selected, Texture[] textures, int approxSize, GUIStyle style, GUIContent errorMessage, out bool doubleClick)
        {
            GUILayout.BeginVertical("box", GUILayout.MinHeight(approxSize));
            int retval = 0;

            doubleClick = false;

            if (textures.Length != 0)
            {
                int   columns = (int)(EditorGUIUtility.currentViewWidth - 150) / approxSize;
                int   rows    = (int)Mathf.Ceil((textures.Length + columns - 1) / columns);
                Rect  r       = GUILayoutUtility.GetAspectRect((float)columns / (float)rows);
                Event evt     = Event.current;
                if (evt.type == EventType.MouseDown && evt.clickCount == 2 && r.Contains(evt.mousePosition))
                {
                    doubleClick = true;
                    evt.Use();
                }

                retval = GUI.SelectionGrid(r, System.Math.Min(selected, textures.Length - 1), textures, (int)columns, style);
            }
            else
            {
                GUILayout.Label(errorMessage);
            }

            GUILayout.EndVertical();
            return(retval);
        }
Esempio n. 6
0
        //[Conditional("ENABLE_DEBUG_TEXTURE")]
        protected void DrawTexture(Texture texture, string label = null, int mip = -1)
        {
            if (texture == null)
            {
                //UnityEngine.Debug.Log("is null");
                return;
            }

            EditorGUILayout.Space();

            int width  = texture.width;
            int height = texture.height;

            if (mip != -1)
            {
                width  /= (int)Math.Pow(2, (double)mip);
                height /= (int)Math.Pow(2, (double)mip);
            }
            if (!string.IsNullOrEmpty(label))
            {
                EditorGUILayout.LabelField(label);
                EditorGUILayout.LabelField(string.Format("    Size: {0} X {1}", width, height));
            }
            else
            {
                EditorGUILayout.LabelField(string.Format("Size: {0} X {1}", width, height));
            }
            //UnityEngine.Debug.Log("is null");
            EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetAspectRect((float)width / height), texture, null, ScaleMode.StretchToFill, 0, mip, UnityEngine.Rendering.ColorWriteMask.All);
        }
Esempio n. 7
0
 private static int DrawFacesList(Texture texture, Rect[] faces, string[] names, int selected)
 {
     GUILayout.BeginHorizontal(GUI.skin.box);
     GUILayout.FlexibleSpace();
     {
         GUILayout.BeginVertical();
         {
             Rect rect = GUILayoutUtility.GetAspectRect(faces.Length, GUILayout.MaxWidth(64 * faces.Length));
             rect.width /= faces.Length;
             for (int i = 0; i < faces.Length; i++)
             {
                 GUI.DrawTextureWithTexCoords(rect, texture, faces[i]);
                 if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition))
                 {
                     selected = i;
                     Event.current.Use();
                 }
                 rect.x += rect.width;
             }
             if (names.Length > 1)
             {
                 GUILayout.Space(4);
                 Rect toolbarRect = GUILayoutUtility.GetRect(0, GUI.skin.button.CalcHeight(GUIContent.none, 0), GUILayout.MaxWidth(64 * faces.Length));
                 selected = GUI.Toolbar(toolbarRect, selected, names);
             }
         }
         GUILayout.EndVertical();
     }
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     return(selected);
 }
Esempio n. 8
0
        public void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_WidthMultiplier, Styles.widthMultiplier, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_Refresh = true;
            }
            Rect aspectRect = GUILayoutUtility.GetAspectRect(2.5f, GUI.skin.textField);

            aspectRect.xMin += EditorGUI.indent;
            if ((Event.current.type != EventType.Layout) && (Event.current.type != EventType.Used))
            {
                this.m_Editor.rect = new Rect(aspectRect.x, aspectRect.y, aspectRect.width, aspectRect.height);
            }
            if (this.m_Refresh)
            {
                this.m_Editor.animationCurves = new CurveWrapper[] { this.GetCurveWrapper(this.m_WidthCurve.animationCurveValue) };
                this.m_Refresh = false;
            }
            GUI.Label(this.m_Editor.drawRect, GUIContent.none, "TextField");
            this.m_Editor.hRangeLocked = Event.current.shift;
            this.m_Editor.vRangeLocked = EditorGUI.actionKey;
            this.m_Editor.OnGUI();
            if ((this.m_Editor.GetCurveWrapperFromID(0) != null) && this.m_Editor.GetCurveWrapperFromID(0).changed)
            {
                AnimationCurve curve = this.m_Editor.GetCurveWrapperFromID(0).curve;
                if (curve.length > 0)
                {
                    this.m_WidthCurve.animationCurveValue          = curve;
                    this.m_Editor.GetCurveWrapperFromID(0).changed = false;
                }
            }
        }
    private void DrawSpriteInInspector(float width, Sprite spriteToDraw)
    {
        float aspect      = (float)spriteToDraw.texture.width / (float)spriteToDraw.texture.height;
        Rect  previewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(width), GUILayout.ExpandWidth(false));

        GUI.DrawTexture(previewRect, spriteToDraw.texture, ScaleMode.ScaleToFit, true, aspect);
    }
Esempio n. 10
0
        public void DrawDebugGUI()
        {
            string label = "Debug";
            string id    = "debug" + water.GetInstanceID().ToString();

            PEditorCommon.Foldout(label, false, id, () =>
            {
                Camera[] cams = water.GetComponentsInChildren <Camera>();
                for (int i = 0; i < cams.Length; ++i)
                {
                    if (!cams[i].name.StartsWith("~"))
                    {
                        continue;
                    }
                    if (cams[i].targetTexture == null)
                    {
                        continue;
                    }
                    EditorGUILayout.LabelField(cams[i].name);
                    Rect r = GUILayoutUtility.GetAspectRect(1);
                    EditorGUI.DrawPreviewTexture(r, cams[i].targetTexture);
                    EditorGUILayout.Space();
                }
            });
        }
Esempio n. 11
0
        private static int SelectionGrid(IList <OCBlock> items, int index, out Rect rect, out int xCount, out int yCount)
        {
            xCount = Mathf.FloorToInt(Screen.width / 66f);
            yCount = Mathf.CeilToInt((float)items.Count / xCount);

            rect = GUILayoutUtility.GetAspectRect((float)xCount / yCount);
            float labelHeight = GUI.skin.label.CalcHeight(GUIContent.none, 0);     // высота текста

            GUILayout.Space(labelHeight * yCount);
            rect.height += labelHeight * yCount;

            Rect[] rects = GUIUtils.Separate(rect, xCount, yCount);
            for (int i = 0; i < items.Count; i++)
            {
                Rect position = rects[i];
                position.xMin += 2;
                position.yMin += 2;

                bool selected = DrawItem(position, items[i], i == index, i);
                if (selected)
                {
                    index = i;
                }
            }

            return(index);
        }
        private void DrawImage(GUISkin skin)
        {
            var     imgPath = Path.Combine(pagePath, m_url);
            Texture img     = null;

            if (m_imgDownload == null)
            {
                img = AssetDatabase.LoadAssetAtPath <Texture>(imgPath);
            }
            else
            {
                var handler = m_imgDownload.downloadHandler as DownloadHandlerTexture;
                if (m_imgDownload.isHttpError || m_imgDownload.isNetworkError)
                {
                    EditorGUILayout.LabelField($"Error loading image: {m_imgDownload.error} @ {m_imgDownload.url}");
                }
                else if (!m_imgDownload.isDone)
                {
                    EditorGUILayout.LabelField($"Loading: {m_imgOp.progress * 100}%");
                }
                else
                {
                    img = handler.texture;
                }
            }

            if (img != null)
            {
                float aspect = (float)img.width / (float)img.height;
                var   pos    = GUILayoutUtility.GetAspectRect(aspect, skin.GetStyle("image"), GUILayout.ExpandWidth(true));
                GUI.DrawTexture(pos, img, ScaleMode.ScaleAndCrop);
            }
        }
Esempio n. 13
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog"));

            EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog"));

            EditorGUILayout.PropertyField(profileSpriteProp, new GUIContent("Image", "Character image sprite to display in the dialog"));

            EditorGUILayout.PropertyField(notesProp, new GUIContent("Notes", "Notes about this story character (personality, attibutes, etc.)"));

            EditorGUILayout.Separator();

            Character t = target as Character;

            if (t.profileSprite != null &&
                spriteMaterial != null)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                float aspect           = (float)t.profileSprite.texture.width / (float)t.profileSprite.texture.height;
                Rect  imagePreviewRect = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(150), GUILayout.ExpandWidth(false));
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                DrawPreview(imagePreviewRect, t.profileSprite.texture);
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 14
0
    public static int AspectSelectionGrid(int selected, Texture[] textures, int approxSize, GUIStyle style,
                                          string emptyString, out bool doubleClick)
    {
        var options = new GUILayoutOption[] { GUILayout.MinHeight(10f) };

        GUILayout.BeginVertical("box", options);
        doubleClick = false;
        var num = 0;

        if (textures != null)
        {
            if (textures.Length != 0)
            {
                var num2       = (Screen.width - 20) / approxSize;
                var num3       = (int)Mathf.Ceil(((float)textures.Length) / num2);
                var aspectRect = GUILayoutUtility.GetAspectRect(num2 / ((float)num3));
                var current    = Event.current;
                if (((current.type == EventType.MouseDown) && (current.clickCount == 2)) &&
                    aspectRect.Contains(current.mousePosition))
                {
                    doubleClick = true;
                    current.Use();
                }
                num = GUI.SelectionGrid(aspectRect, selected, textures, (Screen.width - 20) / approxSize, style);
            }
            else
            {
                GUILayout.Label(emptyString, new GUILayoutOption[0]);
            }
        }
        GUILayout.EndVertical();

        return(num);
    }
Esempio n. 15
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        var generator = target as Perlin;

        if (GUILayout.Button("Generate Seed"))
        {
            generator.Seed = Random.Range(0, (1 << 28));
        }

        if (GUILayout.Button("Generate Image"))
        {
            generator.Generate();
        }

        if (generator.texture != null)
        {
            GUILayout.Space(6);
            var rect = GUILayoutUtility.GetAspectRect(1f, GUIStyle.none);

            // rect.height = rect.width;
            GUI.DrawTexture(rect, generator.texture);
            if (GUILayout.Button("Save As..."))
            {
                var savePath = EditorUtility.SaveFilePanelInProject("Save As...", "NoiseTexture3d", "asset", "", Application.dataPath);
                savePath = savePath.Replace(Application.dataPath, "Assets");
                AssetDatabase.CreateAsset(generator.texture, savePath);
            }
        }
    }
Esempio n. 16
0
        public static void DrawImage(Texture texture)
        {
            float aspect = (float)texture.width / texture.height;
            var   rect   = GUILayoutUtility.GetAspectRect(aspect);

            GUI.DrawTexture(rect, texture, ScaleMode.ScaleToFit, false);
        }
Esempio n. 17
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            Character t = target as Character;

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(nameTextProp, new GUIContent("Name Text", "Name of the character display in the dialog"));
            EditorGUILayout.PropertyField(nameColorProp, new GUIContent("Name Color", "Color of name text display in the dialog"));
            EditorGUILayout.PropertyField(soundEffectProp, new GUIContent("Sound Effect", "Sound to play when the character is talking. Overrides the setting in the Dialog."));
            EditorGUILayout.PropertyField(effectAudioSourceProp);
            EditorGUILayout.PropertyField(voiceAudioSourceProp);
            EditorGUILayout.PropertyField(setSayDialogProp);
            EditorGUILayout.PropertyField(descriptionProp, new GUIContent("Description", "Notes about this story character (personality, attibutes, etc.)"));

            if (t.Portraits != null &&
                t.Portraits.Count > 0)
            {
                t.ProfileSprite = t.Portraits[0];
            }
            else
            {
                t.ProfileSprite = null;
            }

            if (t.ProfileSprite != null)
            {
                Texture2D characterTexture = t.ProfileSprite.texture;
                float     aspect           = (float)characterTexture.width / (float)characterTexture.height;
                Rect      previewRect      = GUILayoutUtility.GetAspectRect(aspect, GUILayout.Width(100), GUILayout.ExpandWidth(true));
                if (characterTexture != null)
                {
                    GUI.DrawTexture(previewRect, characterTexture, ScaleMode.ScaleToFit, true, aspect);
                }
            }

            EditorGUILayout.PropertyField(portraitsProp, new GUIContent("Portraits", "Character image sprites to display in the dialog"), true);

            EditorGUILayout.HelpBox("All portrait images should use the exact same resolution to avoid positioning and tiling issues.", MessageType.Info);

            EditorGUILayout.Separator();

            string[] facingArrows = new string[]
            {
                "FRONT",
                "<--",
                "-->",
            };
            portraitsFaceProp.enumValueIndex = EditorGUILayout.Popup("Portraits Face", (int)portraitsFaceProp.enumValueIndex, facingArrows);

            EditorGUILayout.Separator();

            if (EditorGUI.EndChangeCheck())
            {
                EditorUtility.SetDirty(t);
            }

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 18
0
        public static int AspectSelectionGrid(int selected, Texture[] textures, int approxSize, GUIStyle style,
                                              GUIContent errorMessage)
        {
            GUILayout.BeginVertical("box", GUILayout.MinHeight(approxSize));
            var newSelected = 0;

            if (textures != null && textures.Length != 0)
            {
                var columns = (int)(EditorGUIUtility.currentViewWidth - 150) / approxSize;
                // ReSharper disable once PossibleLossOfFraction
                var rows = (int)Mathf.Ceil((textures.Length + columns - 1) / columns);
                var r    = GUILayoutUtility.GetAspectRect(columns / (float)rows);

                var texturesPreview = new Texture[textures.Length];
                for (var i = 0; i < textures.Length; ++i)
                {
                    texturesPreview[i] = textures[i]
                        ? (AssetPreview.GetAssetPreview(textures[i]) ?? textures[i])
                        : EditorGUIUtility.whiteTexture;
                }

                newSelected = GUI.SelectionGrid(r, Math.Min(selected, texturesPreview.Length - 1), texturesPreview,
                                                columns, style);
            }
            else
            {
                GUILayout.Label(errorMessage);
            }

            GUILayout.EndVertical();
            return(newSelected);
        }
Esempio n. 19
0
    private static IEnumerable <Rect> DrawGrid(int xCount, int yCount)
    {
        var id = GUIUtility.GetControlID("Grid".GetHashCode(), FocusType.Keyboard);

        using (new GUILayout.VerticalScope(GUI.skin.box))
        {
            for (var y = 0; y < yCount; y++)
            {
                using (new GUILayout.HorizontalScope())
                {
                    for (var x = 0; x < xCount; x++)
                    {
                        Rect rect = GUILayoutUtility.GetAspectRect(1);
                        if (Event.current.type == EventType.MouseDown &&
                            rect.Contains(Event.current.mousePosition))
                        {
                            GUIUtility.hotControl = GUIUtility.keyboardControl = id;
                        }

                        yield return(rect);
                    }
                }
            }
        }
    }
    void OnGUI()
    {
        GUILayout.Label($"mat type = {matType}");
        var rect = GUILayoutUtility.GetAspectRect(text.width / (float)text.height);

        EditorGUI.DrawTextureTransparent(rect, text);
    }
Esempio n. 21
0
        int BrushSelectionGrid(int selected, Brush[] brushes, int approxSize, GUIStyle style, GUIContent emptyString, out bool doubleClick)
        {
            GUILayout.BeginVertical("box", GUILayout.MinHeight(approxSize));
            int retval = 0;

            doubleClick = false;

            if (brushes.Length != 0)
            {
                int   columns = (int)(EditorGUIUtility.currentViewWidth - 150) / approxSize;
                int   rows    = (int)Mathf.Ceil((brushes.Length + columns - 1) / columns);
                Rect  r       = GUILayoutUtility.GetAspectRect((float)columns / (float)rows);
                Event evt     = Event.current;
                if (evt.type == EventType.MouseDown && evt.clickCount == 2 && r.Contains(evt.mousePosition))
                {
                    doubleClick = true;
                    evt.Use();
                }

                if (m_Thumnails == null || m_Thumnails.Length != brushes.Length)
                {
                    m_Thumnails = GUIContentFromBrush(brushes);
                }
                retval = GUI.SelectionGrid(r, System.Math.Min(selected, brushes.Length - 1), m_Thumnails, (int)columns, style);
            }
            else
            {
                GUILayout.Label(emptyString);
            }

            GUILayout.EndVertical();
            return(retval);
        }
Esempio n. 22
0
    public override void OnInspectorGUI()
    {
        var funnel = target as Funnel;

        // Screen settings.
        funnel.screenWidth  = EditorGUILayout.IntField("Screen Width", funnel.screenWidth);
        funnel.screenHeight = EditorGUILayout.IntField("Screen Height", funnel.screenHeight);

        // Preview settings.
        funnel.drawGameView = EditorGUILayout.Toggle("Draw Game View", funnel.drawGameView);

        if (funnel.previewOnInspector = EditorGUILayout.Foldout(funnel.previewOnInspector, "Preview"))
        {
            if (EditorApplication.isPlaying)
            {
                var texture = funnel.renderTexture;
                if (texture)
                {
                    EditorGUILayout.Space();
                    var rect = GUILayoutUtility.GetAspectRect(1.0f * texture.width / texture.height);
                    EditorGUILayout.Space();
                    EditorGUI.DrawPreviewTexture(rect, texture);
                    // Make it dirty to stay updated.
                    EditorUtility.SetDirty(target);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("Available only on Play Mode", MessageType.None);
            }
        }
    }
Esempio n. 23
0
 public static void GUI(this RegionOfInterestMsg message, Texture2D tex = null)
 {
     if (tex != null)
     {
         var ratio = (float)tex.width / (float)tex.height;
         UnityEngine.GUI.Box(GUILayoutUtility.GetAspectRect(ratio), tex);
     }
     GUILayout.Label($"x_offset: {message.x_offset}\ny_offset: {message.y_offset}\nHeight: {message.height}\nWidth: {message.width}\nDo rectify: {message.do_rectify}");
 }
Esempio n. 24
0
    /**
     * Backend of method called to draw the atlas texture onto the editor
     */
    private static Rect DrawTexture(Texture texture, Rect texCoords)
    {
        GUILayout.BeginVertical("box");
        Rect rect = GUILayoutUtility.GetAspectRect((float)texture.width / texture.height);

        GUI.DrawTextureWithTexCoords(rect, texture, texCoords);
        GUILayout.EndVertical();
        return(rect);
    }
        public override void OnGUI()
        {
            SetValue(kLatLongExposure, EditorGUILayout.Slider(Content.kLatLongExposureLabel, GetValue(kLatLongExposure), 0, 1));

            var latLongA = GetValue(kLatLongA);

            if (latLongA != null)
            {
                var mat = DelightingService.GetLatLongMaterial(
                    latLongA,
                    GetValue(kNormalsTexture),
                    GetValue(kLatLongAverage),
                    GetValue(kOverrideReferenceZone),
                    GetValue(kLatLongExposure),
                    GetValue(kSafetyZoneParams),
                    false);

                var oldRt = RenderTexture.active;
                m_latLongExposed = DelightingHelpers.InstantiateRTIfRequired(m_latLongExposed, latLongA.width, latLongA.height, false, TextureWrapMode.Clamp);
                DelightingHelpers.PushSRGBWrite(false);
                Graphics.Blit(null, m_latLongExposed, mat);
                DelightingHelpers.PopSRGBWrite();
                RenderTexture.active = oldRt;

                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(Content.kLatLongALabel, EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(Content.kExportLabel))
                {
                    ExecuteCommand(kCmdExportMainEnvMap);
                }
                GUILayout.EndHorizontal();

                EditorGUILayout.Space();

                var rect = GUILayoutUtility.GetAspectRect(latLongA.width / (float)latLongA.height);
                GUI.DrawTexture(rect, m_latLongExposed);
                EditorGUILayout.Space();
            }



            var bakedLut = GetValue(kBakedLUT);

            if (bakedLut != null)
            {
                EditorGUILayout.Space();

                EditorGUILayout.LabelField(Content.kBakedLUTLabel, EditorStyles.boldLabel);

                EditorGUILayout.Space();

                var rect = GUILayoutUtility.GetAspectRect(bakedLut.width / (float)bakedLut.height);
                GUI.DrawTexture(rect, bakedLut);
                EditorGUILayout.Space();
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Draws a texture
        /// </summary>
        /// <param name="texture">The texture to draw</param>
        /// <param name="maxSize">The maximum pixel size</param>
        public static void DrawTexture(Texture2D texture, float maxSize)
        {
            Rect rect        = EditorGUILayout.BeginHorizontal();
            Rect textureRect = GUILayoutUtility.GetAspectRect(texture.width / texture.height, GUILayout.MaxWidth(maxSize));

            textureRect.x += rect.width / 2 - textureRect.width / 2;
            GUI.DrawTexture(textureRect, texture);
            EditorGUILayout.EndHorizontal();
        }
        private void DrawPlayModeGUI()
        {
            var textureAtlas = ((TextureAtlasManager)target).textureAtlas;
            var width        = textureAtlas.texture.width;
            var height       = textureAtlas.texture.height;

            GUILayout.Space(10);
            EditorGUILayout.LabelField(string.Format("Atlas Size: {0} X {1}", width, height));
            EditorGUI.DrawPreviewTexture(GUILayoutUtility.GetAspectRect((float)width / height), textureAtlas.texture);
        }
Esempio n. 28
0
 public static UnityEngine.Object ObjectField(string label, UnityEngine.Object obj, System.Type objType, bool allowSceneObjects, params GUILayoutOption[] options)
 {
     GUILayout.BeginHorizontal(new GUILayoutOption[0]);
     GUILayoutOption[] optionArray1 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
     GUI.Label(GUILayoutUtility.GetRect(EditorGUIUtility.labelWidth, 32f, EditorStyles.label, optionArray1), label, EditorStyles.label);
     GUILayoutOption[]  optionArray2 = new GUILayoutOption[] { GUILayout.Width(64f) };
     UnityEngine.Object obj2         = EditorGUI.ObjectField(GUILayoutUtility.GetAspectRect(1f, EditorStyles.objectField, optionArray2), obj, objType, allowSceneObjects);
     GUILayout.EndHorizontal();
     return(obj2);
 }
Esempio n. 29
0
 public static Rect DrawTexture(Texture2D texture)
 {
     if ((UnityEngine.Object)texture != (UnityEngine.Object)null)
     {
         Rect aspectRect = GUILayoutUtility.GetAspectRect((float)texture.width / (float)texture.height, GUILayout.ExpandWidth(true));
         GUI.DrawTexture(aspectRect, texture, ScaleMode.ScaleAndCrop);
         return(aspectRect);
     }
     return(default(Rect));
 }
        public void LightmapPreview(Rect r)
        {
            if (LightingWindowLightmapPreviewTab.s_Styles == null)
            {
                LightingWindowLightmapPreviewTab.s_Styles = new LightingWindowLightmapPreviewTab.Styles();
            }
            bool flag = true;

            GUI.Box(r, string.Empty, "PreBackground");
            this.m_ScrollPositionLightmaps = EditorGUILayout.BeginScrollView(this.m_ScrollPositionLightmaps, new GUILayoutOption[]
            {
                GUILayout.Height(r.height)
            });
            int   num  = 0;
            float num2 = 2f;

            LightmapData[] lightmaps = LightmapSettings.lightmaps;
            for (int i = 0; i < lightmaps.Length; i++)
            {
                LightmapData lightmapData = lightmaps[i];
                if (lightmapData.lightmapFar == null && lightmapData.lightmapNear == null)
                {
                    num++;
                }
                else
                {
                    int               num3      = (!lightmapData.lightmapFar) ? -1 : Math.Max(lightmapData.lightmapFar.width, lightmapData.lightmapFar.height);
                    int               num4      = (!lightmapData.lightmapNear) ? -1 : Math.Max(lightmapData.lightmapNear.width, lightmapData.lightmapNear.height);
                    Texture2D         texture2D = (num3 <= num4) ? lightmapData.lightmapNear : lightmapData.lightmapFar;
                    GUILayoutOption[] options   = new GUILayoutOption[]
                    {
                        GUILayout.MaxWidth((float)texture2D.width * num2),
                        GUILayout.MaxHeight((float)texture2D.height)
                    };
                    Rect aspectRect = GUILayoutUtility.GetAspectRect((float)texture2D.width * num2 / (float)texture2D.height, options);
                    if (flag)
                    {
                        LightingWindowLightmapPreviewTab.Header(ref aspectRect, 20f, 6f, num2);
                        flag = false;
                    }
                    aspectRect.width /= num2;
                    EditorGUI.DrawPreviewTexture(aspectRect, lightmapData.lightmapFar);
                    this.MenuSelectLightmapUsers(aspectRect, num);
                    if (lightmapData.lightmapNear)
                    {
                        aspectRect.x += aspectRect.width;
                        EditorGUI.DrawPreviewTexture(aspectRect, lightmapData.lightmapNear);
                        this.MenuSelectLightmapUsers(aspectRect, num);
                    }
                    num++;
                }
            }
            EditorGUILayout.EndScrollView();
        }