Пример #1
0
        internal static unsafe void DrawLayoutMode(Rect position, LayoutMode hMode, LayoutMode vMode, bool doPivot, bool doPosition)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            Color color = GUI.color;
            int   num   = (int)Mathf.Min(position.width, position.height);

            if ((num % 2) == 0)
            {
                num--;
            }
            int num2 = num / 2;

            if ((num2 % 2) == 0)
            {
                num2++;
            }
            Vector2 vector  = (Vector2)(num * Vector2.one);
            Vector2 vector2 = (Vector2)(num2 * Vector2.one);
            Vector2 vector3 = (Vector2)((position.size - vector) / 2f);

            vector3.x = Mathf.Floor(vector3.x);
            vector3.y = Mathf.Floor(vector3.y);
            Vector2 vector4 = (Vector2)((position.size - vector2) / 2f);

            vector4.x = Mathf.Floor(vector4.x);
            vector4.y = Mathf.Floor(vector4.y);
            Rect rect  = new Rect(position.x + vector3.x, position.y + vector3.y, vector.x, vector.y);
            Rect rect2 = new Rect(position.x + vector4.x, position.y + vector4.y, vector2.x, vector2.y);

            if (doPosition)
            {
                for (int j = 0; j < 2; j++)
                {
                    ref Vector2 vectorRef;
                    switch (((j != 0) ? vMode : hMode))
                    {
                    case LayoutMode.Min:
                    {
                        int     num4;
                        Vector2 center = rect2.center;
                        (vectorRef = (Vector2) & center)[num4 = j] = vectorRef[num4] + (rect.min[j] - rect2.min[j]);
                        rect2.center = center;
                        break;
                    }

                    case LayoutMode.Max:
                    {
                        int     num5;
                        Vector2 vector8 = rect2.center;
                        (vectorRef = (Vector2) & vector8)[num5 = j] = vectorRef[num5] + (rect.max[j] - rect2.max[j]);
                        rect2.center = vector8;
                        break;
                    }

                    case LayoutMode.Stretch:
                    {
                        Vector2 min = rect2.min;
                        Vector2 max = rect2.max;
                        min[j]    = rect.min[j];
                        max[j]    = rect.max[j];
                        rect2.min = min;
                        rect2.max = max;
                        break;
                    }
                    }
                }
            }
        private void Draw(Rect rect)
        {
            var settings = m_SceneView.cameraSettings;

            Styles.Init();

            const int k_SettingsIconPad = 2;
            Vector2   settingsSize      = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.titleSettingsIcon);
            Rect      settingsRect      = new Rect(rect.xMax - Styles.settingsArea.padding.right - k_SettingsIconPad - settingsSize.x, Styles.settingsArea.padding.top + k_SettingsIconPad, settingsSize.x, settingsSize.y);

            if (GUI.Button(settingsRect, EditorGUI.GUIContents.titleSettingsIcon, EditorStyles.iconButton))
            {
                ShowContextMenu();
            }

            GUILayout.BeginArea(rect, Styles.settingsArea);

            EditorGUI.BeginChangeCheck();

            EditorGUIUtility.labelWidth = kPrefixLabelWidth;

            GUILayout.Label(EditorGUIUtility.TrTextContent("Scene Camera"), EditorStyles.boldLabel);

            // fov isn't applicable in orthographic mode, and orthographic size is controlled by the user zoom
            using (new EditorGUI.DisabledScope(m_SceneView.orthographic))
            {
                settings.fieldOfView = EditorGUILayout.Slider(m_FieldOfView, settings.fieldOfView, 4f, 179f);
            }

            settings.dynamicClip = EditorGUILayout.Toggle(m_DynamicClip, settings.dynamicClip);

            using (new EditorGUI.DisabledScope(settings.dynamicClip))
            {
                float near = settings.nearClip, far = settings.farClip;
                DrawClipPlanesField(EditorGUI.s_ClipingPlanesLabel, ref near, ref far, EditorGUI.kNearFarLabelsWidth);
                settings.nearClip = near;
                settings.farClip  = far;
                settings.nearClip = Mathf.Max(kNearClipMin, settings.nearClip);
                if (settings.nearClip > settings.farClip)
                {
                    settings.farClip = settings.nearClip + kNearClipMin;
                }
            }

            settings.occlusionCulling = EditorGUILayout.Toggle(m_OcclusionCulling, settings.occlusionCulling);

            if (EditorGUI.EndChangeCheck())
            {
                m_SceneView.Repaint();
            }

            GUILayout.Label(EditorGUIUtility.TrTextContent("Navigation"), EditorStyles.boldLabel);

            settings.easingEnabled = EditorGUILayout.Toggle(m_EasingEnabled, settings.easingEnabled);

            using (new EditorGUI.DisabledScope(!settings.easingEnabled))
            {
                EditorGUI.indentLevel  += 1;
                settings.easingDuration = EditorGUILayout.Slider(m_EasingDuration, settings.easingDuration, .1f, 2f);
                EditorGUI.indentLevel  -= 1;
            }

            settings.speed = EditorGUILayout.Slider(m_CameraSpeedSliderContent, settings.speed, settings.speedMin, settings.speedMax);

            EditorGUI.BeginChangeCheck();

            m_Vector2Floats[0] = settings.speedMin;
            m_Vector2Floats[1] = settings.speedMax;

            DrawSpeedMinMaxFields();

            if (EditorGUI.EndChangeCheck())
            {
                settings.SetSpeedMinMax(m_Vector2Floats);
            }

            EditorGUIUtility.labelWidth = 0f;

            GUILayout.EndArea();
        }
        // showPerAxisWrapModes is state of whether "Per-Axis" mode should be active in the main dropdown.
        // It is set automatically if wrap modes in UVW are different, or if user explicitly picks "Per-Axis" option -- when that one is picked,
        // then it should stay true even if UVW wrap modes will initially be the same.
        //
        // Note: W wrapping mode is only shown when isVolumeTexture is true.
        internal static void WrapModePopup(SerializedProperty wrapU, SerializedProperty wrapV, SerializedProperty wrapW, bool isVolumeTexture, ref bool showPerAxisWrapModes)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            // In texture importer settings, serialized properties for things like wrap modes can contain -1;
            // that seems to indicate "use defaults, user has not changed them to anything" but not totally sure.
            // Show them as Repeat wrap modes in the popups.
            var wu = (TextureWrapMode)Mathf.Max(wrapU.intValue, 0);
            var wv = (TextureWrapMode)Mathf.Max(wrapV.intValue, 0);
            var ww = (TextureWrapMode)Mathf.Max(wrapW.intValue, 0);

            // automatically go into per-axis mode if values are already different
            if (wu != wv)
            {
                showPerAxisWrapModes = true;
            }
            if (isVolumeTexture)
            {
                if (wu != ww || wv != ww)
                {
                    showPerAxisWrapModes = true;
                }
            }

            // It's not possible to determine whether any single texture in the whole selection is using per-axis wrap modes
            // just from SerializedProperty values. They can only tell if "some values in whole selection are different" (e.g.
            // wrap value on U axis is not the same among all textures), and can return value of "some" object in the selection
            // (typically based on object loading order). So in order for more intuitive behavior with multi-selection,
            // we go over the actual objects when there's >1 object selected and some wrap modes are different.
            if (!showPerAxisWrapModes)
            {
                if (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues))
                {
                    if (IsAnyTextureObjectUsingPerAxisWrapMode(wrapU.serializedObject.targetObjects, isVolumeTexture))
                    {
                        showPerAxisWrapModes = true;
                    }
                }
            }

            int value = showPerAxisWrapModes ? -1 : (int)wu;

            // main wrap mode popup
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = !showPerAxisWrapModes && (wrapU.hasMultipleDifferentValues || wrapV.hasMultipleDifferentValues || (isVolumeTexture && wrapW.hasMultipleDifferentValues));
            value = EditorGUILayout.IntPopup(s_Styles.wrapModeLabel, value, s_Styles.wrapModeContents, s_Styles.wrapModeValues);
            if (EditorGUI.EndChangeCheck() && value != -1)
            {
                // assign the same wrap mode to all axes, and hide per-axis popups
                wrapU.intValue       = value;
                wrapV.intValue       = value;
                wrapW.intValue       = value;
                showPerAxisWrapModes = false;
            }

            // show per-axis popups if needed
            if (value == -1)
            {
                showPerAxisWrapModes = true;
                EditorGUI.indentLevel++;
                WrapModeAxisPopup(s_Styles.wrapU, wrapU);
                WrapModeAxisPopup(s_Styles.wrapV, wrapV);
                if (isVolumeTexture)
                {
                    WrapModeAxisPopup(s_Styles.wrapW, wrapW);
                }
                EditorGUI.indentLevel--;
            }
            EditorGUI.showMixedValue = false;
        }
        void OnGUI()
        {
            if (styles == null)
            {
                styles            = new Styles();
                styles.toggleSize = styles.toggle.CalcSize(new GUIContent("X"));
            }

            if (!UnityConnect.instance.canBuildWithUPID)
            {
                ShowAlert();
            }
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            GUILayout.BeginVertical();

            string message             = "";
            var    buildSettingsLocked = !AssetDatabase.IsOpenForEdit(kEditorBuildSettingsPath, out message, StatusQueryOptions.UseCachedIfPossible);

            using (new EditorGUI.DisabledScope(buildSettingsLocked))
            {
                ActiveScenesGUI();
                // Clear all and Add Current Scene
                GUILayout.BeginHorizontal();
                if (buildSettingsLocked)
                {
                    GUI.enabled = true;

                    if (Provider.enabled && GUILayout.Button(styles.checkOut))
                    {
                        Asset asset     = Provider.GetAssetByPath(kEditorBuildSettingsPath);
                        var   assetList = new AssetList();
                        assetList.Add(asset);
                        Provider.Checkout(assetList, CheckoutMode.Asset);
                    }
                    GUILayout.Label(message);
                    GUI.enabled = false;
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(styles.addOpenSource))
                {
                    AddOpenScenes();
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(10);

            GUILayout.BeginHorizontal(GUILayout.Height(351));
            ActiveBuildTargetsGUI();
            GUILayout.Space(10);
            GUILayout.BeginVertical();
            ShowBuildTargetSettings();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            GUILayout.EndVertical();
            GUILayout.Space(10);
            GUILayout.EndHorizontal();
        }
Пример #5
0
        public override void OnInspectorGUI()
        {
            if (styles == null)
            {
                // Set the singleton in case the DrawEditors() has created this window
                s_SharedAssetStoreAssetInspector = this;
                styles = new Styles();
            }

            AssetStoreAsset activeAsset = AssetStoreAssetSelection.GetFirstAsset();

            AssetStoreAsset.PreviewInfo info = null;
            if (activeAsset != null)
            {
                info = activeAsset.previewInfo;
            }

            if (activeAsset != null)
            {
                target.name = string.Format("Asset Store: {0}", activeAsset.name);
            }
            else
            {
                target.name = "Asset Store";
            }

            EditorGUILayout.BeginVertical();

            bool guiEnabled = GUI.enabled;

            GUI.enabled = activeAsset != null && activeAsset.packageID != 0;

            if (OfflineNoticeEnabled)
            {
                Color col = GUI.color;
                GUI.color = Color.yellow;
                GUILayout.Label("Network is offline");
                GUI.color = col;
            }

            if (activeAsset != null)
            {
                string typeName  = activeAsset.className == null ? "" : activeAsset.className.Split(new char[] { ' ' }, 2)[0];
                bool   isPackage = activeAsset.id == -activeAsset.packageID;
                if (isPackage)
                {
                    typeName = "Package";
                }
                if (activeAsset.HasLivePreview)
                {
                    typeName = activeAsset.Preview.GetType().Name;
                }
                EditorGUILayout.LabelField("Type", typeName);

                if (isPackage)
                {
                    packageInfoShown = true;
                }
                else
                {
                    EditorGUILayout.Separator();
                    packageInfoShown = EditorGUILayout.Foldout(packageInfoShown, "Part of package", true);
                }
                if (packageInfoShown)
                {
                    EditorGUILayout.LabelField("Name", info == null ? "-" : info.packageName);
                    EditorGUILayout.LabelField("Version", info == null ? "-" : info.packageVersion);
                    string price = info == null ? "-" : (!string.IsNullOrEmpty(activeAsset.price) ? activeAsset.price : "free");
                    EditorGUILayout.LabelField("Price", price);
                    string rating = info != null && info.packageRating >= 0 ? info.packageRating + " of 5" : "-";
                    EditorGUILayout.LabelField("Rating", rating);
                    EditorGUILayout.LabelField("Size", info == null ? "-" : intToSizeString(info.packageSize));
                    string assetCount = info != null && info.packageAssetCount >= 0 ? info.packageAssetCount.ToString() : "-";
                    EditorGUILayout.LabelField("Asset count", assetCount);
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Web page");
                    bool hasPageUrl = info != null && info.packageShortUrl != null && info.packageShortUrl != "";
                    bool guiBefore  = GUI.enabled;
                    GUI.enabled = hasPageUrl;

                    if (GUILayout.Button(hasPageUrl ? new GUIContent(info.packageShortUrl, "View in browser") : EditorGUIUtility.TempContent("-"), styles.link))
                    {
                        Application.OpenURL(info.packageShortUrl);
                    }
                    if (GUI.enabled)
                    {
                        EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
                    }
                    GUI.enabled = guiBefore;
                    GUILayout.EndHorizontal();
                    EditorGUILayout.LabelField("Publisher", info == null ? "-" : info.publisherName);
                }

                if (activeAsset.id != 0)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();

                    string actionLabel;
                    if (info != null && info.isDownloadable)
                    {
                        actionLabel = "Import package";
                    }
                    else
                    {
                        actionLabel = "Buy for " + activeAsset.price;
                    }

                    bool lastEnabled = GUI.enabled;
                    bool building    = info != null && info.buildProgress >= 0;
                    bool downloading = info != null && info.downloadProgress >= 0;
                    if (building || downloading || info == null)
                    {
                        actionLabel = "";
                        GUI.enabled = false;
                    }

                    if (GUILayout.Button(actionLabel, GUILayout.Height(40), GUILayout.Width(120)))
                    {
                        if (info != null && info.isDownloadable)
                        {
                            ImportPackage(activeAsset);
                        }
                        else
                        {
                            InitiateBuySelected();
                        }
                        GUIUtility.ExitGUI();
                    }

                    Rect r;
                    if (Event.current.type == EventType.Repaint)
                    {
                        r         = GUILayoutUtility.GetLastRect();
                        r.height -= 4;
                        float width = r.width;
                        r.width = r.height;
                        r.y    += 2;
                        r.x    += 2;

                        if (building || downloading)
                        {
                            r.width = width - r.height - 4;
                            r.x    += r.height;
                            EditorGUI.ProgressBar(r,
                                                  downloading ? info.downloadProgress : info.buildProgress,
                                                  downloading ? "Downloading" : "Building");
                        }
                    }

                    GUI.enabled = lastEnabled;
                    GUILayout.Space(4);

                    if (GUILayout.Button("Open Asset Store", GUILayout.Height(40), GUILayout.Width(120)))
                    {
                        OpenItemInAssetStore(activeAsset);
                        GUIUtility.ExitGUI();
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
                GUILayout.FlexibleSpace();
            }
            EditorWrapper editor = previewEditor;

            if (editor != null && activeAsset != null && activeAsset.HasLivePreview)
            {
                editor.OnAssetStoreInspectorGUI();
            }

            GUI.enabled = guiEnabled;

            EditorGUILayout.EndVertical();
        }
Пример #6
0
        public override void OnPreviewSettings()
        {
            if (IsCubemap())
            {
                m_CubemapPreview.OnPreviewSettings(targets);
                return;
            }

            if (IsTexture2DArray() && !SystemInfo.supports2DArrayTextures)
            {
                return;
            }

            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            // TextureInspector code is reused for RenderTexture and Cubemap inspectors.
            // Make sure we can handle the situation where target is just a Texture and
            // not a Texture2D. It's also used for large popups for mini texture fields,
            // and while it's being shown the actual texture object might disappear --
            // make sure to handle null targets.
            Texture tex       = target as Texture;
            bool    alphaOnly = false;
            bool    hasAlpha  = true;
            int     mipCount  = 1;

            if (target is Texture2D)
            {
                alphaOnly = true;
                hasAlpha  = false;
            }

            foreach (Texture t in targets)
            {
                if (t == null) // texture might have disappeared while we're showing this in a preview popup
                {
                    continue;
                }
                TextureFormat format      = 0;
                bool          checkFormat = false;
                if (t is Texture2D)
                {
                    format      = (t as Texture2D).format;
                    checkFormat = true;
                }

                if (checkFormat)
                {
                    if (!TextureUtil.IsAlphaOnlyTextureFormat(format))
                    {
                        alphaOnly = false;
                    }
                    if (TextureUtil.HasAlphaTextureFormat(format))
                    {
                        TextureUsageMode mode = TextureUtil.GetUsageMode(t);
                        if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha
                        {
                            hasAlpha = true;
                        }
                    }
                }

                mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t));
            }


            List <PreviewMode> previewCandidates = new List <PreviewMode>(5);

            previewCandidates.Add(PreviewMode.RGB);
            previewCandidates.Add(PreviewMode.R);
            previewCandidates.Add(PreviewMode.G);
            previewCandidates.Add(PreviewMode.B);
            previewCandidates.Add(PreviewMode.A);

            if (alphaOnly)
            {
                previewCandidates.Clear();
                previewCandidates.Add(PreviewMode.A);
                m_PreviewMode = PreviewMode.A;
            }
            else if (!hasAlpha)
            {
                previewCandidates.Remove(PreviewMode.A);
            }


            if (previewCandidates.Count > 1 && tex != null && !IsNormalMap(tex))
            {
                int selectedIndex = previewCandidates.IndexOf(m_PreviewMode);
                if (selectedIndex == -1)
                {
                    selectedIndex = 0;
                }

                if (previewCandidates.Contains(PreviewMode.RGB))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.RGB, s_Styles.previewButtonContents[0], s_Styles.toolbarButton)
                        ? PreviewMode.RGB
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.R))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.R, s_Styles.previewButtonContents[1], s_Styles.toolbarButton)
                        ? PreviewMode.R
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.G))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.G, s_Styles.previewButtonContents[2], s_Styles.toolbarButton)
                        ? PreviewMode.G
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.B))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.B, s_Styles.previewButtonContents[3], s_Styles.toolbarButton)
                        ? PreviewMode.B
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.A))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.A, s_Styles.previewButtonContents[4], s_Styles.toolbarButton)
                        ? PreviewMode.A
                        : m_PreviewMode;
                }
            }

            if (mipCount > 1)
            {
                GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel);
                GUI.changed = false;
                m_MipLevel  = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, s_Styles.previewSlider, s_Styles.previewSliderThumb, GUILayout.MaxWidth(64)));
                GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel);
            }
        }
        public override void OnInspectorGUI()
        {
            if (styles == null)
            {
                styles = new Styles();
            }

            var rts = target as RayTracingShader;

            if (rts == null)
            {
                return;
            }

            serializedObject.Update();

            GUI.enabled = true;

            EditorGUI.indentLevel = 0;

            if (ShowPlatformListSection(rts))
            {
                EditorGUILayout.Space();

                EditorGUILayout.PropertyField(m_MaxRecursionDepth, styles.s_MaxRecursionDepthText);

                int rayGenShaderCount = ShaderUtil.GetRayGenerationShaderCount(rts);
                if (rayGenShaderCount > 0)
                {
                    GUILayout.Space(15.0f);
                    GUILayout.Label(styles.s_RayGenShaderNames, styles.s_LabelStyle);

                    string[] rayGenShaderNames = new string[rayGenShaderCount];
                    for (int i = 0; i < rayGenShaderCount; i++)
                    {
                        rayGenShaderNames[i] = ShaderUtil.GetRayGenerationShaderName(rts, i);
                    }

                    ShowRayGenerationShaderList(rayGenShaderNames);
                }

                int missShaderCount = ShaderUtil.GetMissShaderCount(rts);
                if (missShaderCount > 0)
                {
                    GUILayout.Space(15.0f);

                    GUILayout.Label(styles.s_MissShaderNames, styles.s_LabelStyle);

                    string[] missShaderNames       = new string[missShaderCount];
                    int[]    missShaderPayloadSize = new int[missShaderCount];
                    for (int i = 0; i < missShaderCount; i++)
                    {
                        missShaderNames[i]       = ShaderUtil.GetMissShaderName(rts, i);
                        missShaderPayloadSize[i] = ShaderUtil.GetMissShaderRayPayloadSize(rts, i);
                    }

                    ShowMissShaderList(missShaderNames, missShaderPayloadSize);
                }

                int callableShaderCount = ShaderUtil.GetCallableShaderCount(rts);
                if (callableShaderCount > 0)
                {
                    GUILayout.Space(15.0f);

                    GUILayout.Label(styles.s_CallableShaderNames, styles.s_LabelStyle);

                    string[] callableShaderNames      = new string[callableShaderCount];
                    int[]    callableShaderParamsSize = new int[callableShaderCount];
                    for (int i = 0; i < callableShaderCount; i++)
                    {
                        callableShaderNames[i]      = ShaderUtil.GetCallableShaderName(rts, i);
                        callableShaderParamsSize[i] = ShaderUtil.GetCallableShaderParamSize(rts, i);
                    }

                    ShowCallableShaderList(callableShaderNames, callableShaderParamsSize);
                }
            }
            else
            {
                EditorGUILayout.HelpBox(styles.s_NotSupported.text, MessageType.Error);
            }

            ShowShaderErrors(rts);
        }
Пример #8
0
        public void OnGUI()
        {
            if (styles == null)
            {
                styles = new Styles();
            }

            LoadLogos();

            if (AssetStoreClient.LoginInProgress() || AssetStoreClient.LoggedIn())
            {
                GUI.enabled = false;
            }

            GUILayout.BeginVertical();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.Label(s_AssetStoreLogo, GUIStyle.none, GUILayout.ExpandWidth(false));
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Space(6);
            GUILayout.Label(m_LoginReason, EditorStyles.wordWrappedLabel);
            Rect lastReasonRect = GUILayoutUtility.GetLastRect();

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Space(6);
            Rect lastMessageRect = new Rect(0f, 0f, 0f, 0f);

            if (m_LoginRemoteMessage != null)
            {
                Color oldColor = GUI.color;
                GUI.color = Color.red;
                GUILayout.Label(m_LoginRemoteMessage, EditorStyles.wordWrappedLabel);
                GUI.color       = oldColor;
                lastMessageRect = GUILayoutUtility.GetLastRect();
            }
            float newHeight = lastReasonRect.height + lastMessageRect.height + kBaseHeight;

            if (Event.current.type == EventType.Repaint && newHeight != position.height)
            {
                // Debug.Log(newHeight.ToString() + " " + position.height + " " + lastReasonRect.height.ToString() + " " + lastMessageRect.height.ToString());
                position = new Rect(position.x, position.y, position.width, newHeight);
                Repaint();
            }
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUI.SetNextControlName("username");
            m_Username = EditorGUILayout.TextField("Username", m_Username);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            m_Password = EditorGUILayout.PasswordField("Password", m_Password, GUILayout.ExpandWidth(true));
            if (GUILayout.Button(EditorGUIUtility.TrTextContent("Forgot?", "Reset your password"), styles.link, GUILayout.ExpandWidth(false)))
            {
                Application.OpenURL("https://accounts.unity3d.com/password/new");
            }

            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();

            bool oldRememberMe = AssetStoreClient.RememberSession;
            bool newRememberMe = EditorGUILayout.Toggle("Remember me", oldRememberMe);

            if (newRememberMe != oldRememberMe)
            {
                AssetStoreClient.RememberSession = newRememberMe;
            }

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

            GUILayout.Space(8);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Create account"))
            {
                AssetStore.Open("createuser/");
                m_LoginRemoteMessage = "Cancelled - create user";
                Close();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                m_LoginRemoteMessage = "Cancelled";
                Close();
            }
            GUILayout.Space(5);
            if (GUILayout.Button("Login"))
            {
                DoLogin();
                Repaint();
            }
            GUILayout.Space(5);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.EndVertical();

            if (Event.current.Equals(Event.KeyboardEvent("return")))
            {
                DoLogin();
                Repaint();
            }

            if (m_Username == "")
            {
                EditorGUI.FocusTextInControl("username");
            }
        }
Пример #9
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            using (new EditorGUI.DisabledScope(false))
            {
                var isManagedPlugin = importers.All(x => x.dllType == DllType.ManagedNET35 || x.dllType == DllType.ManagedNET40);
                if (isManagedPlugin)
                {
                    ShowReferenceOptions();
                    GUILayout.Space(10f);
                }

                GUILayout.Label(Styles.kPluginPlatforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                ShowGeneralOptions();
                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                if (IsEditingPlatformSettingsSupported())
                {
                    ShowPlatformSettings();
                }

                if (isManagedPlugin)
                {
                    GUILayout.Label(Styles.kDefineConstraints, EditorStyles.boldLabel);

                    if (m_DefineConstraints.list.Count > 0)
                    {
                        var defines = InternalEditorUtility.GetCompilationDefines(EditorScriptCompilationOptions.BuildingForEditor, EditorUserBuildSettings.activeBuildTargetGroup, EditorUserBuildSettings.activeBuildTarget);

                        var defineConstraintsCompatible = true;

                        if (defines != null)
                        {
                            for (var i = 0; i < m_DefineConstraints.list.Count && defineConstraintsCompatible; ++i)
                            {
                                var defineConstraint = ((DefineConstraint)m_DefineConstraints.list[i]).name;

                                if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible)
                                {
                                    defineConstraintsCompatible = false;
                                }
                            }

                            var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect());
                            constraintValidityRect.x = constraintValidityRect.width - Styles.kValidityIconWidth / 4;
                            var image   = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint;
                            var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible);
                            var content = new GUIContent(image, tooltip);

                            constraintValidityRect.width  = Styles.kValidityIconWidth;
                            constraintValidityRect.height = Styles.kValidityIconHeight;
                            EditorGUI.LabelField(constraintValidityRect, content);
                        }
                    }

                    m_DefineConstraints.DoLayoutList();
                }

                if (importers.All(imp => imp.isNativePlugin))
                {
                    GUILayout.Space(10f);
                    GUILayout.Label(Styles.kLoadSettings, EditorStyles.boldLabel);
                    ShowLoadSettings();
                }
            }

            serializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();

            // Don't output additional information if we have multiple plugins selected
            if (targets.Length > 1)
            {
                return;
            }

            GUILayout.Label(Styles.kInformation, EditorStyles.boldLabel);

            m_InformationScrollPosition = EditorGUILayout.BeginVerticalScrollView(m_InformationScrollPosition);

            foreach (var prop in m_PluginInformation)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(prop.Key, GUILayout.Width(85));
                EditorGUILayout.SelectableLabel(prop.Value, GUILayout.Height(EditorGUI.kSingleLineHeight));
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();
            GUILayout.FlexibleSpace();

            // Warning for Case 648027
            // Once Mono loads a native plugin, it never releases a handle, thus plugin is never unloaded.
            if (importer.isNativePlugin)
            {
                EditorGUILayout.HelpBox("Once a native plugin is loaded from script, it's never unloaded. If you deselect a native plugin and it's already loaded, please restart Unity.", MessageType.Warning);
            }
        }
Пример #10
0
        public void ObjectPreview(Rect r)
        {
            if (r.height > 0f)
            {
                if (s_Styles == null)
                {
                    s_Styles = new Styles();
                }
                List <Texture2D> list = new List <Texture2D>();
                foreach (GITextureType type in this.kObjectPreviewTextureTypes)
                {
                    list.Add(LightmapVisualizationUtility.GetGITexture(type));
                }
                if (list.Count != 0)
                {
                    Rect rect3;
                    Rect rect9;
                    if (this.m_ZoomablePreview == null)
                    {
                        this.m_ZoomablePreview           = new ZoomableArea(true);
                        this.m_ZoomablePreview.hRangeMin = 0f;
                        this.m_ZoomablePreview.vRangeMin = 0f;
                        this.m_ZoomablePreview.hRangeMax = 1f;
                        this.m_ZoomablePreview.vRangeMax = 1f;
                        this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                        this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                        this.m_ZoomablePreview.uniformScale    = true;
                        this.m_ZoomablePreview.scaleWithWindow = true;
                    }
                    GUI.Box(r, string.Empty, "PreBackground");
                    Rect position = new Rect(r);
                    position.y++;
                    position.height = 18f;
                    GUI.Box(position, string.Empty, EditorStyles.toolbar);
                    Rect rect2 = new Rect(r);
                    rect2.y++;
                    rect2.height = 18f;
                    rect2.width  = 120f;
                    rect3        = new Rect(r)
                    {
                        yMin  = rect3.yMin + rect2.height,
                        yMax  = rect3.yMax - 14f,
                        width = rect3.width - 11f
                    };
                    int index = Array.IndexOf <GUIContent>(kObjectPreviewTextureOptions, this.m_SelectedObjectPreviewTexture);
                    if (index < 0)
                    {
                        index = 0;
                    }
                    index = EditorGUI.Popup(rect2, index, kObjectPreviewTextureOptions, EditorStyles.toolbarPopup);
                    if (index >= kObjectPreviewTextureOptions.Length)
                    {
                        index = 0;
                    }
                    this.m_SelectedObjectPreviewTexture = kObjectPreviewTextureOptions[index];
                    LightmapType       lightmapType = ((this.kObjectPreviewTextureTypes[index] != GITextureType.Baked) && (this.kObjectPreviewTextureTypes[index] != GITextureType.BakedDirectional)) ? LightmapType.DynamicLightmap : LightmapType.StaticLightmap;
                    SerializedProperty property     = new SerializedObject(LightmapEditorSettings.GetLightmapSettings()).FindProperty("m_LightmapsMode");
                    bool flag = ((this.kObjectPreviewTextureTypes[index] == GITextureType.Baked) || (this.kObjectPreviewTextureTypes[index] == GITextureType.BakedDirectional)) && (property.intValue == 2);
                    if (flag)
                    {
                        GUIContent content = GUIContent.Temp("Indirect");
                        Rect       rect4   = rect2;
                        rect4.x    += rect2.width;
                        rect4.width = EditorStyles.toolbarButton.CalcSize(content).x;
                        this.m_HasSeparateIndirectUV = GUI.Toggle(rect4, this.m_HasSeparateIndirectUV, content.text, EditorStyles.toolbarButton);
                    }
                    switch (Event.current.type)
                    {
                    case EventType.ValidateCommand:
                    case EventType.ExecuteCommand:
                        if (Event.current.commandName == "FrameSelected")
                        {
                            Rect    rect5;
                            Vector4 lightmapTilingOffset = LightmapVisualizationUtility.GetLightmapTilingOffset(lightmapType);
                            Vector2 lhs     = new Vector2(lightmapTilingOffset.z, lightmapTilingOffset.w);
                            Vector2 vector3 = lhs + new Vector2(lightmapTilingOffset.x, lightmapTilingOffset.y);
                            lhs     = Vector2.Max(lhs, Vector2.zero);
                            vector3 = Vector2.Min(vector3, Vector2.one);
                            float num3 = 1f - lhs.y;
                            lhs.y     = 1f - vector3.y;
                            vector3.y = num3;
                            rect5     = new Rect(lhs.x, lhs.y, vector3.x - lhs.x, vector3.y - lhs.y)
                            {
                                x = rect5.x - (Mathf.Clamp(rect5.height - rect5.width, 0f, float.MaxValue) / 2f),
                                y = rect5.y - (Mathf.Clamp(rect5.width - rect5.height, 0f, float.MaxValue) / 2f)
                            };
                            float num5 = Mathf.Max(rect5.width, rect5.height);
                            rect5.height = num5;
                            rect5.width  = num5;
                            if (flag && this.m_HasSeparateIndirectUV)
                            {
                                rect5.x += 0.5f;
                            }
                            this.m_ZoomablePreview.shownArea = rect5;
                            Event.current.Use();
                        }
                        break;

                    case EventType.Repaint:
                    {
                        Texture2D texture = list[index];
                        if ((texture != null) && (Event.current.type == EventType.Repaint))
                        {
                            Rect rect7;
                            Rect rect8;
                            Rect rect = new Rect(0f, 0f, (float)texture.width, (float)texture.height);
                            rect  = this.ResizeRectToFit(rect, rect3);
                            rect  = this.CenterToRect(rect, rect3);
                            rect  = this.ScaleRectByZoomableArea(rect, this.m_ZoomablePreview);
                            rect7 = new Rect(rect)
                            {
                                x = rect7.x + 3f,
                                y = rect7.y + (rect3.y + 20f)
                            };
                            rect8 = new Rect(rect3)
                            {
                                y = rect8.y + (rect2.height + 3f)
                            };
                            float num4 = rect8.y - 14f;
                            rect7.y -= num4;
                            rect8.y -= num4;
                            FilterMode filterMode = texture.filterMode;
                            texture.filterMode = FilterMode.Point;
                            GITextureType textureType    = this.kObjectPreviewTextureTypes[index];
                            bool          drawSpecularUV = flag && this.m_HasSeparateIndirectUV;
                            LightmapVisualizationUtility.DrawTextureWithUVOverlay(texture, Selection.activeGameObject, rect8, rect7, textureType, drawSpecularUV);
                            texture.filterMode = filterMode;
                        }
                        break;
                    }
                    }
                    if (this.m_PreviousSelection != Selection.activeInstanceID)
                    {
                        this.m_PreviousSelection = Selection.activeInstanceID;
                        this.m_ZoomablePreview.SetShownHRange(0f, 1f);
                        this.m_ZoomablePreview.SetShownVRange(0f, 1f);
                    }
                    rect9 = new Rect(r)
                    {
                        yMin = rect9.yMin + rect2.height
                    };
                    this.m_ZoomablePreview.rect = rect9;
                    this.m_ZoomablePreview.BeginViewGUI();
                    this.m_ZoomablePreview.EndViewGUI();
                    GUILayoutUtility.GetRect(r.width, r.height);
                }
            }
        }
Пример #11
0
        internal static void DrawPreview(IPreviewable defaultPreview, Rect previewArea, UnityEngine.Object[] targets)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            string infoString = string.Empty;
            Event  current    = Event.current;

            if (targets.Length > 1)
            {
                Rect  rect      = new RectOffset(0x10, 0x10, 20, 0x19).Remove(previewArea);
                int   num       = Mathf.Max(1, Mathf.FloorToInt((rect.height + 10f) / 77f));
                int   num2      = Mathf.Max(1, Mathf.FloorToInt((rect.width + 10f) / 65f));
                int   num3      = num * num2;
                int   minimumNr = Mathf.Min(targets.Length, 0x19);
                bool  flag      = true;
                int[] numArray  = new int[] { num2, num };
                if (minimumNr < num3)
                {
                    numArray = GetGridDivision(rect, minimumNr, 12);
                    flag     = false;
                }
                int num5 = Mathf.Min(numArray[0] * numArray[1], targets.Length);
                rect.width  += 10f;
                rect.height += 10f;
                Vector2 vector = new Vector2((float)Mathf.FloorToInt((rect.width / ((float)numArray[0])) - 10f), (float)Mathf.FloorToInt((rect.height / ((float)numArray[1])) - 10f));
                float   a      = Mathf.Min(vector.x, vector.y - 12f);
                if (flag)
                {
                    a = Mathf.Min(a, 55f);
                }
                bool flag2 = (((current.type == EventType.MouseDown) && (current.button == 0)) && (current.clickCount == 2)) && previewArea.Contains(current.mousePosition);
                defaultPreview.ResetTarget();
                for (int i = 0; i < num5; i++)
                {
                    Rect position = new Rect(rect.x + (((i % numArray[0]) * rect.width) / ((float)numArray[0])), rect.y + (((i / numArray[0]) * rect.height) / ((float)numArray[1])), vector.x, vector.y);
                    if (flag2 && position.Contains(Event.current.mousePosition))
                    {
                        Selection.objects = new UnityEngine.Object[] { defaultPreview.target };
                    }
                    position.height -= 12f;
                    Rect rect3 = new Rect(position.x + ((position.width - a) * 0.5f), position.y + ((position.height - a) * 0.5f), a, a);
                    GUI.BeginGroup(rect3);
                    Editor.m_AllowMultiObjectAccess = false;
                    defaultPreview.OnInteractivePreviewGUI(new Rect(0f, 0f, a, a), s_Styles.preBackgroundSolid);
                    Editor.m_AllowMultiObjectAccess = true;
                    GUI.EndGroup();
                    position.y      = rect3.yMax;
                    position.height = 16f;
                    GUI.Label(position, targets[i].name, s_Styles.previewMiniLabel);
                    defaultPreview.MoveNextTarget();
                }
                defaultPreview.ResetTarget();
                if (Event.current.type == EventType.Repaint)
                {
                    infoString = $"Previewing {num5} of {targets.Length} Objects";
                }
            }
            else
            {
                defaultPreview.OnInteractivePreviewGUI(previewArea, s_Styles.preBackground);
                if (Event.current.type == EventType.Repaint)
                {
                    infoString = defaultPreview.GetInfoString();
                    if (infoString != string.Empty)
                    {
                        infoString = infoString.Replace("\n", "   ");
                        infoString = $"{defaultPreview.target.name}
{infoString}";
                    }
                }
            }
            if ((Event.current.type == EventType.Repaint) && (infoString != string.Empty))
            {
                float height = s_Styles.dropShadowLabelStyle.CalcHeight(GUIContent.Temp(infoString), previewArea.width);
                EditorGUI.DropShadowLabel(new Rect(previewArea.x, (previewArea.yMax - height) - 5f, previewArea.width, height), infoString);
            }
        }
Пример #12
0
        public static void DoFixerUI(GameObject gameObject)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            var srpAsset = GraphicsSettings.currentRenderPipeline;

            var defaultSpeedTree8Shader = srpAsset != null ? srpAsset.defaultSpeedTree8Shader : null;

            if (defaultSpeedTree8Shader == null)
            {
                defaultSpeedTree8Shader = Shader.Find("Nature/SpeedTree8");
            }

            var defaultSpeedTree7Shader = srpAsset != null ? srpAsset.defaultSpeedTree7Shader : null;

            if (defaultSpeedTree7Shader == null)
            {
                defaultSpeedTree7Shader = Shader.Find("Nature/SpeedTree");
            }

            if (defaultSpeedTree8Shader == null || defaultSpeedTree7Shader == null)
            {
                return;
            }

            HashSet <Material> materialsUsedForBothVersion = null, speedTreeV7MaterialsToFix = null, speedTreeV8MaterialsToFix = null;

            foreach (var meshRenderer in EnumerateMeshRenderers(gameObject))
            {
                var meshFilter = meshRenderer.GetComponent <MeshFilter>();
                if (meshFilter == null)
                {
                    continue;
                }

                var mesh = meshFilter.sharedMesh;
                if (mesh == null || !EditorUtility.IsPersistent(mesh))
                {
                    continue;
                }

                var assetPath         = AssetDatabase.GetAssetPath(mesh);
                var speedTreeImporter = AssetImporter.GetAtPath(assetPath) as SpeedTreeImporter;
                if (speedTreeImporter == null)
                {
                    continue;
                }

                if (materialsUsedForBothVersion == null)
                {
                    materialsUsedForBothVersion = new HashSet <Material>();
                    speedTreeV7MaterialsToFix   = new HashSet <Material>();
                    speedTreeV8MaterialsToFix   = new HashSet <Material>();
                }

                bool meshIsV8 = speedTreeImporter.isV8;
                foreach (var material in meshRenderer.sharedMaterials)
                {
                    if (material == null)
                    {
                        continue;
                    }

                    // If the material is used for both v7 & v8 mesh: ignore.
                    if (materialsUsedForBothVersion.Contains(material))
                    {
                        continue;
                    }

                    // We only fix materials with wrong speedtree shader assigned. We don't know if it's "wrong" if user uses their custom shaders.
                    var wrongShader = meshIsV8 ? defaultSpeedTree7Shader : defaultSpeedTree8Shader;
                    if (material.shader != wrongShader)
                    {
                        continue;
                    }

                    var targetMaterialSet = meshIsV8 ? speedTreeV8MaterialsToFix : speedTreeV7MaterialsToFix;
                    var otherMaterialSet  = meshIsV8 ? speedTreeV7MaterialsToFix : speedTreeV8MaterialsToFix;

                    if (otherMaterialSet.Contains(material))
                    {
                        // rare case that the same material is used both for v7 & v8 material:
                        materialsUsedForBothVersion.Add(material);
                        otherMaterialSet.Remove(material);
                    }
                    else
                    {
                        targetMaterialSet.Add(material);
                    }
                }
            }

            // No speedtree meshes.
            if (materialsUsedForBothVersion == null)
            {
                return;
            }

            if (speedTreeV7MaterialsToFix.Count > 0 || speedTreeV8MaterialsToFix.Count > 0)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(s_Styles.Message, MessageType.Error);
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(s_Styles.FixSpeedTreeShaders, GUILayout.ExpandWidth(false)))
                {
                    Undo.RecordObjects(speedTreeV7MaterialsToFix.Concat(speedTreeV8MaterialsToFix).ToArray(), "Fix SpeedTree Shaders");
                    foreach (var material in speedTreeV7MaterialsToFix)
                    {
                        material.shader = defaultSpeedTree7Shader;
                    }
                    foreach (var material in speedTreeV8MaterialsToFix)
                    {
                        material.shader = defaultSpeedTree8Shader;
                    }
                }
                GUILayout.EndHorizontal();
            }

            if (materialsUsedForBothVersion.Count != 0)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("Some of the materials are used for both SpeedTree 7 and SpeedTree 8 assets. Unity won't be able to fix that. Please create separate materials.", MessageType.Error);
            }
        }
Пример #13
0
        void OnGUI()
        {
            if (ms_Styles == null)
            {
                ms_Styles = new Styles();
            }

            GUILayout.Space(5);

            EditorGUI.BeginChangeCheck();
            Vector3 m = move;

            m.x = EditorGUILayout.FloatField(ms_Styles.moveX, m.x);
            m.y = EditorGUILayout.FloatField(ms_Styles.moveY, m.y);
            m.z = EditorGUILayout.FloatField(ms_Styles.moveZ, m.z);

            if (EditorGUI.EndChangeCheck())
            {
                if (m.x <= 0)
                {
                    m.x = move.x;
                }
                if (m.y <= 0)
                {
                    m.y = move.y;
                }
                if (m.z <= 0)
                {
                    m.z = move.z;
                }
                move = m;
            }
            scale    = EditorGUILayout.FloatField(ms_Styles.scale, scale);
            rotation = EditorGUILayout.FloatField(ms_Styles.rotation, rotation);

            GUILayout.Space(5);

            bool snapX = false, snapY = false, snapZ = false;

            GUILayout.BeginHorizontal();
            if (GUILayout.Button(ms_Styles.snapAllAxes, ms_Styles.buttonLeft))
            {
                snapX = true; snapY = true; snapZ = true;
            }
            if (GUILayout.Button(ms_Styles.snapX, ms_Styles.buttonMid))
            {
                snapX = true;
            }
            if (GUILayout.Button(ms_Styles.snapY, ms_Styles.buttonMid))
            {
                snapY = true;
            }
            if (GUILayout.Button(ms_Styles.snapZ, ms_Styles.buttonRight))
            {
                snapZ = true;
            }
            GUILayout.EndHorizontal();

            if (snapX | snapY | snapZ)
            {
                Vector3 scaleTmp = new Vector3(1.0f / move.x, 1.0f / move.y, 1.0f / move.z);

                Undo.RecordObjects(Selection.transforms, "Snap " + (Selection.transforms.Length == 1 ? Selection.activeGameObject.name : " selection") + " to grid");
                foreach (Transform t in Selection.transforms)
                {
                    Vector3 pos = t.position;
                    if (snapX)
                    {
                        pos.x = Mathf.Round(pos.x * scaleTmp.x) / scaleTmp.x;
                    }
                    if (snapY)
                    {
                        pos.y = Mathf.Round(pos.y * scaleTmp.y) / scaleTmp.y;
                    }
                    if (snapZ)
                    {
                        pos.z = Mathf.Round(pos.z * scaleTmp.z) / scaleTmp.z;
                    }
                    t.position = pos;
                }
            }
        }
Пример #14
0
        public override void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            Event evt = Event.current;

            Rect contentRect = new Rect(0, 0, 1, CalcSize().y);

            m_ScrollPosition = GUI.BeginScrollView(rect, m_ScrollPosition, contentRect);
            {
                float curY = 2f;
                for (int i = 0; i <= maxIndex; ++i)
                {
                    int  itemControlID = i + 1000000;
                    Rect itemRect      = new Rect(0, curY, rect.width, lineHeight);
                    bool addSeperator  = Array.IndexOf(m_SeperatorIndices, i) >= 0;

                    // Add new preset button
                    if (m_ShowAddNewPresetItem && i == m_ItemProvider.Count())
                    {
                        CreateNewItemButton(itemRect);
                        continue;
                    }

                    if (m_ShowEditWindowForIndex == i)
                    {
                        m_ShowEditWindowForIndex = -1;
                        EditExistingItem(itemRect, i);
                    }

                    // Handle event
                    switch (evt.type)
                    {
                    case EventType.Repaint:
                        bool hover = false;
                        if (m_HoverIndex == i)
                        {
                            if (itemRect.Contains(evt.mousePosition))
                            {
                                hover = true;
                            }
                            else
                            {
                                m_HoverIndex = -1;
                            }
                        }

                        // Overwrite if
                        if (m_ModifyItemUI != null && m_ModifyItemUI.IsShowing())
                        {
                            hover = m_ItemProvider.GetItem(i) == m_ModifyItemUI.m_Object;
                        }

                        s_Styles.menuItem.Draw(itemRect, GUIContent.Temp(m_ItemProvider.GetName(i)), hover, false, i == selectedIndex, false);

                        if (addSeperator)
                        {
                            const float margin        = 4f;
                            Rect        seperatorRect = new Rect(itemRect.x + margin, itemRect.y + itemRect.height + seperatorHeight * 0.5f, itemRect.width - 2 * margin, 1);
                            DrawRect(seperatorRect, (EditorGUIUtility.isProSkin) ? new Color(0.32f, 0.32f, 0.32f, 1.333f) : new Color(0.6f, 0.6f, 0.6f, 1.333f));     // dark : light
                        }

                        // We delete presets on alt-click
                        if (AllowDeleteClick(i))
                        {
                            EditorGUIUtility.AddCursorRect(itemRect, MouseCursor.ArrowMinus);
                        }
                        break;

                    case EventType.MouseDown:
                        if (evt.button == 0 && itemRect.Contains(evt.mousePosition))
                        {
                            GUIUtility.hotControl = itemControlID;
                            if (!IsDeleteModiferPressed() && evt.clickCount == 1)
                            {
                                GUIUtility.hotControl = 0;
                                SelectItem(i);
                                editorWindow.Close();
                                evt.Use();
                            }
                        }
                        break;

                    case EventType.MouseUp:
                        if (GUIUtility.hotControl == itemControlID)
                        {
                            GUIUtility.hotControl = 0;
                            if (evt.button == 0 && itemRect.Contains(evt.mousePosition))
                            {
                                if (AllowDeleteClick(i))
                                {
                                    DeleteItem(i);
                                    evt.Use();
                                }
                            }
                        }
                        break;

                    case EventType.ContextClick:
                        if (itemRect.Contains(evt.mousePosition))
                        {
                            evt.Use();
                            if (m_ModifyItemUI != null && m_ItemProvider.IsModificationAllowed(i))
                            {
                                ItemContextMenu.Show(i, this);
                            }
                        }
                        break;

                    case EventType.MouseMove:
                        if (itemRect.Contains(evt.mousePosition))
                        {
                            if (m_HoverIndex != i)
                            {
                                m_HoverIndex = i;
                                Repaint();
                            }
                        }
                        else if (m_HoverIndex == i)
                        {
                            m_HoverIndex = -1;
                            Repaint();
                        }
                        break;
                    }

                    curY += lineHeight;
                    if (addSeperator)
                    {
                        curY += seperatorHeight;
                    }
                } // end foreach item
            } GUI.EndScrollView();
        }
Пример #15
0
        private void OnGUI()
        {
            bool flag = Event.current.type == EventType.MouseUp;

            if (this.delegateView == null)
            {
                this.m_Curve = null;
            }
            if (ms_Styles == null)
            {
                ms_Styles = new Styles();
            }
            this.m_CurveEditor.rect         = this.GetCurveEditorRect();
            this.m_CurveEditor.hRangeLocked = Event.current.shift;
            this.m_CurveEditor.vRangeLocked = EditorGUI.actionKey;
            GUI.changed = false;
            GUI.Label(this.m_CurveEditor.drawRect, GUIContent.none, ms_Styles.curveEditorBackground);
            this.m_CurveEditor.BeginViewGUI();
            this.m_CurveEditor.GridGUI();
            this.m_CurveEditor.CurveGUI();
            this.DoWrapperPopups();
            this.m_CurveEditor.EndViewGUI();
            GUI.Box(new Rect(0f, base.position.height - 46f, base.position.width, 46f), string.Empty, ms_Styles.curveSwatchArea);
            this.m_Color.a *= 0.6f;
            float y = (base.position.height - 46f) + 10.5f;

            this.InitCurvePresets();
            CurvePresetLibrary currentLib = this.m_CurvePresets.GetPresetLibraryEditor().GetCurrentLib();

            if (currentLib != null)
            {
                for (int i = 0; i < currentLib.Count(); i++)
                {
                    Rect position = new Rect(45f + (45f * i), y, 40f, 25f);
                    this.m_GUIContent.tooltip = currentLib.GetName(i);
                    if (GUI.Button(position, this.m_GUIContent, ms_Styles.curveSwatch))
                    {
                        AnimationCurve preset = currentLib.GetPreset(i) as AnimationCurve;
                        this.m_Curve.keys         = preset.keys;
                        this.m_Curve.postWrapMode = preset.postWrapMode;
                        this.m_Curve.preWrapMode  = preset.preWrapMode;
                        this.m_CurveEditor.SelectNone();
                        this.SendEvent("CurveChanged", true);
                    }
                    if (Event.current.type == EventType.Repaint)
                    {
                        currentLib.Draw(position, i);
                    }
                    if (position.xMax > (base.position.width - 90f))
                    {
                        break;
                    }
                }
            }
            Rect rect2 = new Rect(25f, y + 5f, 20f, 20f);

            this.PresetDropDown(rect2);
            if ((Event.current.type == EventType.Used) && flag)
            {
                this.DoUpdateCurve(false);
                this.SendEvent("CurveChangeCompleted", true);
            }
            else if ((Event.current.type != EventType.Layout) && (Event.current.type != EventType.Repaint))
            {
                this.DoUpdateCurve(true);
            }
        }
Пример #16
0
        private void OnGUI()
        {
            if (ms_Styles == null)
            {
                ms_Styles = new Styles();
            }
            GUILayout.Space(5f);
            EditorGUI.BeginChangeCheck();
            Vector3 move = SnapSettings.move;

            move.x = EditorGUILayout.FloatField(ms_Styles.moveX, move.x, new GUILayoutOption[0]);
            move.y = EditorGUILayout.FloatField(ms_Styles.moveY, move.y, new GUILayoutOption[0]);
            move.z = EditorGUILayout.FloatField(ms_Styles.moveZ, move.z, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                if (move.x <= 0f)
                {
                    move.x = SnapSettings.move.x;
                }
                if (move.y <= 0f)
                {
                    move.y = SnapSettings.move.y;
                }
                if (move.z <= 0f)
                {
                    move.z = SnapSettings.move.z;
                }
                SnapSettings.move = move;
            }
            scale    = EditorGUILayout.FloatField(ms_Styles.scale, scale, new GUILayoutOption[0]);
            rotation = EditorGUILayout.FloatField(ms_Styles.rotation, rotation, new GUILayoutOption[0]);
            GUILayout.Space(5f);
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button(ms_Styles.snapAllAxes, ms_Styles.buttonLeft, new GUILayoutOption[0]))
            {
                flag  = true;
                flag2 = true;
                flag3 = true;
            }
            if (GUILayout.Button(ms_Styles.snapX, ms_Styles.buttonMid, new GUILayoutOption[0]))
            {
                flag = true;
            }
            if (GUILayout.Button(ms_Styles.snapY, ms_Styles.buttonMid, new GUILayoutOption[0]))
            {
                flag2 = true;
            }
            if (GUILayout.Button(ms_Styles.snapZ, ms_Styles.buttonRight, new GUILayoutOption[0]))
            {
                flag3 = true;
            }
            GUILayout.EndHorizontal();
            if ((flag | flag2) | flag3)
            {
                Vector3 vector2 = new Vector3(1f / SnapSettings.move.x, 1f / SnapSettings.move.y, 1f / SnapSettings.move.z);
                Undo.RecordObjects(Selection.transforms, "Snap " + ((Selection.transforms.Length != 1) ? " selection" : Selection.activeGameObject.name) + " to grid");
                foreach (Transform transform in Selection.transforms)
                {
                    Vector3 position = transform.position;
                    if (flag)
                    {
                        float introduced15 = Mathf.Round(position.x * vector2.x);
                        position.x = introduced15 / vector2.x;
                    }
                    if (flag2)
                    {
                        float introduced16 = Mathf.Round(position.y * vector2.y);
                        position.y = introduced16 / vector2.y;
                    }
                    if (flag3)
                    {
                        float introduced17 = Mathf.Round(position.z * vector2.z);
                        position.z = introduced17 / vector2.z;
                    }
                    transform.position = position;
                }
            }
        }
Пример #17
0
        public override void OnInspectorGUI()
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            base.serializedObject.Update();
            this.UpdateShowOptions(false);
            EditorGUILayout.PropertyField(this.m_Type, new GUILayoutOption[0]);
            if (EditorGUILayout.BeginFadeGroup(1f - this.m_ShowAreaOptions.faded))
            {
                EditorGUILayout.IntPopup(this.m_Lightmapping, s_Styles.LightmappingModes, s_Styles.LightmappingModeValues, s_Styles.LightmappingModeLabel, new GUILayoutOption[0]);
                if (EditorGUILayout.BeginFadeGroup(this.m_ShowBakingWarning.faded))
                {
                    EditorGUILayout.HelpBox(EditorGUIUtility.TextContent("Enable Baked GI from Lighting window to use Baked or Mixed.").text, MessageType.Warning, false);
                }
                EditorGUILayout.EndFadeGroup();
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.Space();
            float num = !((!this.m_ShowDirOptions.isAnimating || !this.m_ShowAreaOptions.isAnimating) ? false : (this.m_ShowDirOptions.target ? true : this.m_ShowAreaOptions.target)) ? (1f - Mathf.Max(this.m_ShowDirOptions.faded, this.m_ShowAreaOptions.faded)) : 0f;

            if (EditorGUILayout.BeginFadeGroup(num))
            {
                EditorGUILayout.PropertyField(this.m_Range, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowSpotOptions.faded))
            {
                EditorGUILayout.Slider(this.m_SpotAngle, 1f, 179f, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowAreaOptions.faded))
            {
                EditorGUILayout.PropertyField(this.m_AreaSizeX, EditorGUIUtility.TextContent("Width"), new GUILayoutOption[0]);
                EditorGUILayout.PropertyField(this.m_AreaSizeY, EditorGUIUtility.TextContent("Height"), new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.PropertyField(this.m_Color, new GUILayoutOption[0]);
            EditorGUILayout.Slider(this.m_Intensity, 0f, 8f, new GUILayoutOption[0]);
            EditorGUILayout.Slider(this.m_BounceIntensity, 0f, 8f, s_Styles.LightBounceIntensity, new GUILayoutOption[0]);
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowIndirectWarning.faded))
            {
                EditorGUILayout.HelpBox(EditorGUIUtility.TextContent("Currently realtime indirect bounce light shadowing for spot and point lights is not supported.").text, MessageType.Warning, false);
            }
            EditorGUILayout.EndFadeGroup();
            this.ShadowsGUI();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowRuntimeOptions.faded))
            {
                EditorGUILayout.PropertyField(this.m_Cookie, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            if (EditorGUILayout.BeginFadeGroup(this.m_ShowRuntimeOptions.faded * this.m_ShowDirOptions.faded))
            {
                EditorGUILayout.PropertyField(this.m_CookieSize, new GUILayoutOption[0]);
            }
            EditorGUILayout.EndFadeGroup();
            EditorGUILayout.PropertyField(this.m_Halo, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_Flare, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_RenderMode, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_CullingMask, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            if ((SceneView.currentDrawingSceneView != null) && !SceneView.currentDrawingSceneView.m_SceneLighting)
            {
                EditorGUILayout.HelpBox(EditorGUIUtility.TextContent("One of your scene views has lighting disabled, please keep this in mind when editing lighting.").text, MessageType.Warning, false);
            }
            base.serializedObject.ApplyModifiedProperties();
        }
Пример #18
0
        void OnGUI()
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
                minSize  = new Vector2(500, 300);
                position = new Rect(position.x, position.y, minSize.x, minSize.y);
            }

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.Space(10);
            GUILayout.Label("Unity is about to save the following modified files. Unsaved changes will be lost!");
            GUILayout.Space(10);
            GUILayout.EndHorizontal();
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);

            int prevSelectedRow = m_LV.row;
            int numSelected     = 0;

            foreach (ListViewElement el in ListViewGUILayout.ListView(m_LV, s_Styles.box))
            {
                if (m_SelectedItems[el.row] && Event.current.type == EventType.Repaint)
                {
                    Rect box = el.position;
                    box.x      += 1;
                    box.y      += 1;
                    box.width  -= 1;
                    box.height -= 1;
                    s_Styles.selected.Draw(box, false, false, false, false);
                }

                GUILayout.Label(m_Content[el.row]);

                if (ListViewGUILayout.HasMouseUp(el.position))
                {
                    Event.current.command = true;
                    Event.current.control = true;
                    ListViewGUILayout.MultiSelection(prevSelectedRow, el.row, ref m_InitialSelectedItem, ref m_SelectedItems);
                }
                if (m_SelectedItems[el.row])
                {
                    numSelected++;
                }
            }

            GUILayout.Space(10);
            GUILayout.EndHorizontal();
            GUILayout.Space(10);

            GUILayout.BeginHorizontal();
            GUILayout.Space(10);

            if (GUILayout.Button(s_Styles.close, s_Styles.button, GUILayout.Width(s_Styles.buttonWidth)))
            {
                CloseWindow();
            }

            GUILayout.FlexibleSpace();

            GUI.enabled = numSelected > 0;

            bool allSelected = numSelected == m_Assets.Count;

            if (GUILayout.Button(s_Styles.dontSave, s_Styles.button, GUILayout.Width(s_Styles.buttonWidth)))
            {
                IgnoreSelectedAssets();
            }

            if (GUILayout.Button(allSelected ? s_Styles.saveAll : s_Styles.saveSelected,
                                 s_Styles.button, GUILayout.Width(s_Styles.buttonWidth)))
            {
                SaveSelectedAssets();
            }

            GUI.enabled = true;

            GUILayout.Space(10);
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            if (m_Assets.Count == 0)
            {
                CloseWindow();
            }
        }
Пример #19
0
        internal void OnGUI()
        {
            // Here due to static vars being thrown out when reloading assemblies
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }

            // Escape pressed?
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                CloseWindow();
            }

            Texture2D selectedIcon          = m_MultipleSelectedIcons ? null : EditorGUIUtility.GetIconForObject(m_TargetObject);
            bool      isSelectionALabelIcon = false;

            if (Event.current.type == EventType.Repaint)
            {
                selectedIcon = ConvertLargeIconToSmallIcon(selectedIcon, ref isSelectionALabelIcon);
            }

            Event     evt       = Event.current;
            EventType eventType = evt.type;

            GUI.BeginGroup(new Rect(0, 0, position.width, position.height), m_Styles.background);

            DoTopSection(selectedIcon != null || m_MultipleSelectedIcons);

            GUILayout.Space(22);
            GUILayout.BeginHorizontal();
            GUILayout.Space(1);
            GUI.enabled = false;
            GUILayout.Label("", m_Styles.seperator);
            GUI.enabled = true;
            GUILayout.Space(1);
            GUILayout.EndHorizontal();
            GUILayout.Space(3);

            if (m_ShowLabelIcons)
            {
                // Label icons
                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                for (int i = 0; i < m_LabelIcons.Length / 2; ++i)
                {
                    DoButton(m_LabelIcons[i], selectedIcon, true);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5);

                GUILayout.BeginHorizontal();
                GUILayout.Space(6);
                for (int i = m_LabelIcons.Length / 2; i < m_LabelIcons.Length; ++i)
                {
                    DoButton(m_LabelIcons[i], selectedIcon, true);
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(3);
                GUILayout.BeginHorizontal();
                GUILayout.Space(1);
                GUI.enabled = false;
                GUILayout.Label("", m_Styles.seperator);
                GUI.enabled = true;
                GUILayout.Space(1);
                GUILayout.EndHorizontal();
                GUILayout.Space(3);
            }

            // Small icons
            GUILayout.BeginHorizontal();
            GUILayout.Space(9);
            for (int i = 0; i < m_SmallIcons.Length / 2; ++i)
            {
                DoButton(m_SmallIcons[i], selectedIcon, false);
            }
            GUILayout.Space(3);
            GUILayout.EndHorizontal();

            GUILayout.Space(6);

            GUILayout.BeginHorizontal();
            GUILayout.Space(9);
            for (int i = m_SmallIcons.Length / 2; i < m_SmallIcons.Length; ++i)
            {
                DoButton(m_SmallIcons[i], selectedIcon, false);
            }
            GUILayout.Space(3);
            GUILayout.EndHorizontal();
            GUILayout.Space(6);

            // Object selector section
            GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
            bool clicked = false;
            int  id      = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(s_Other))
            {
                GUIUtility.keyboardControl = id;
                clicked = true;
            }
            GUI.backgroundColor = new Color(1, 1, 1, 1);
            GUI.EndGroup();

            if (clicked)
            {
                ObjectSelector.get.Show(m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = id;
                GUI.backgroundColor = new Color(1, 1, 1, 0.7f);
                evt.Use();
                GUIUtility.ExitGUI();
            }

            // Check for icon selected from ObjectSelector
            switch (eventType)
            {
            case EventType.ExecuteCommand:
                string commandName = evt.commandName;
                if (commandName == ObjectSelector.ObjectSelectorUpdatedCommand && ObjectSelector.get.objectSelectorID == id && GUIUtility.keyboardControl == id)
                {
                    Texture2D icon = ObjectSelector.GetCurrentObject() as Texture2D;
                    SetIconForSelectedObjects(icon);

                    GUI.changed = true;
                    evt.Use();
                }
                break;

            case EventType.ValidateCommand:
                if (evt.commandName == EventCommandNames.UndoRedoPerformed)
                {
                    CloseWindow();
                    GUI.changed = true;
                    evt.Use();
                }
                break;
            }
        }
Пример #20
0
        internal static void DrawPreview(IPreviewable defaultPreview, Rect previewArea, UnityObject[] targets)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            string text = string.Empty;
            Event  evt  = Event.current;

            // If multiple targets, draw a grid of previews
            if (targets.Length > 1)
            {
                // Draw the previews inside the region of the background that's solid colored
                Rect previewPositionInner = new RectOffset(16, 16, 20, 25).Remove(previewArea);

                // Number of previews to aim at
                int maxRows = Mathf.Max(1, Mathf.FloorToInt((previewPositionInner.height + kGridSpacing) / (kPreviewMinSize + kGridSpacing + kPreviewLabelHeight)));
                int maxCols = Mathf.Max(1, Mathf.FloorToInt((previewPositionInner.width + kGridSpacing) / (kPreviewMinSize + kGridSpacing)));
                int countWithMinimumSize = maxRows * maxCols;
                int neededCount          = Mathf.Min(targets.Length, kGridTargetCount);

                // Get number of columns and rows
                bool  fixedSize = true;
                int[] division  = new int[2] {
                    maxCols, maxRows
                };
                if (neededCount < countWithMinimumSize)
                {
                    division  = GetGridDivision(previewPositionInner, neededCount, kPreviewLabelHeight);
                    fixedSize = false;
                }

                // The available cells in the grid may be slightly higher than what was aimed at.
                // If the number of targets is also higher, we might as well fill in the remaining cells.
                int count = Mathf.Min(division[0] * division[1], targets.Length);

                // Calculations become simpler if we add one spacing to the width and height,
                // so there is the same number of spaces and previews.
                previewPositionInner.width  += kGridSpacing;
                previewPositionInner.height += kGridSpacing;

                Vector2 cellSize = new Vector2(
                    Mathf.FloorToInt(previewPositionInner.width / division[0] - kGridSpacing),
                    Mathf.FloorToInt(previewPositionInner.height / division[1] - kGridSpacing)
                    );
                float previewSize = Mathf.Min(cellSize.x, cellSize.y - kPreviewLabelHeight);
                if (fixedSize)
                {
                    previewSize = Mathf.Min(previewSize, kPreviewMinSize);
                }

                bool selectingOne = (evt.type == EventType.MouseDown && evt.button == 0 && evt.clickCount == 2 &&
                                     previewArea.Contains(evt.mousePosition));

                defaultPreview.ResetTarget();
                for (int i = 0; i < count; i++)
                {
                    Rect r = new Rect(
                        previewPositionInner.x + (i % division[0]) * previewPositionInner.width / division[0],
                        previewPositionInner.y + (i / division[0]) * previewPositionInner.height / division[1],
                        cellSize.x,
                        cellSize.y
                        );

                    if (selectingOne && r.Contains(Event.current.mousePosition))
                    {
                        if (defaultPreview.target is AssetImporter)
                        {
                            // The new selection should be the asset itself, not the importer
                            Selection.objects = new[] { AssetDatabase.LoadAssetAtPath <UnityObject>(((AssetImporter)defaultPreview.target).assetPath) }
                        }
                        ;
                        else
                        {
                            Selection.objects = new UnityObject[] { defaultPreview.target }
                        };
                    }

                    // Make room for label underneath
                    r.height -= kPreviewLabelHeight;
                    // Make preview square
                    Rect rSquare = new Rect(r.x + (r.width - previewSize) * 0.5f, r.y + (r.height - previewSize) * 0.5f, previewSize, previewSize);

                    // Draw preview inside a group to prevent overdraw
                    // @TODO: Make style with solid color that doesn't have overdraw
                    GUI.BeginGroup(rSquare);
                    Editor.m_AllowMultiObjectAccess = false;
                    defaultPreview.OnInteractivePreviewGUI(new Rect(0, 0, previewSize, previewSize), s_Styles.preBackgroundSolid);
                    Editor.m_AllowMultiObjectAccess = true;
                    GUI.EndGroup();

                    // Draw the name of the object
                    r.y      = rSquare.yMax;
                    r.height = 16;
                    GUI.Label(r, targets[i].name, s_Styles.previewMiniLabel);
                    defaultPreview.MoveNextTarget();
                }
                defaultPreview.ResetTarget();  // Remember to reset referenceTargetIndex to prevent following calls to 'editor.target' will return a different target which breaks all sorts of places. Fix for case 600235

                if (Event.current.type == EventType.Repaint)
                {
                    text = string.Format("Previewing {0} of {1} Objects", count, targets.Length);
                }
            }
            // If only a single target, just draw that one
            else
            {
                defaultPreview.OnInteractivePreviewGUI(previewArea, s_Styles.preBackground);

                if (Event.current.type == EventType.Repaint)
                {
                    // TODO: This should probably be calculated during import and stored together with the asset somehow. Or maybe not. Not sure, really...
                    text = defaultPreview.GetInfoString();
                    if (text != string.Empty)
                    {
                        text = text.Replace("\n", "   ");
                        text = string.Format("{0}\n{1}", defaultPreview.target.name, text);
                    }
                }
            }

            // Draw the asset info.
            if (Event.current.type == EventType.Repaint && text != string.Empty)
            {
                var textHeight = s_Styles.dropShadowLabelStyle.CalcHeight(GUIContent.Temp(text), previewArea.width);
                EditorGUI.DropShadowLabel(new Rect(previewArea.x, previewArea.yMax - textHeight - kPreviewLabelPadding, previewArea.width, textHeight), text);
            }
        }
Пример #21
0
        public override void OnInspectorGUI()
        {
            if (initializeException != null)
            {
                ShowLoadErrorExceptionGUI(initializeException);
                ApplyRevertGUI();
                return;
            }

            extraDataSerializedObject.Update();

            var platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms();

            using (new EditorGUI.DisabledScope(false))
            {
                if (targets.Length > 1)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        var value = string.Join(", ", extraDataTargets.Select(t => t.name).ToArray());
                        EditorGUILayout.TextField(Styles.name, value, EditorStyles.textField);
                    }
                }
                else
                {
                    EditorGUILayout.PropertyField(m_AssemblyName, Styles.name);
                }

                GUILayout.Label(Styles.generalOptions, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_AllowUnsafeCode, Styles.allowUnsafeCode);
                EditorGUILayout.PropertyField(m_AutoReferenced, Styles.autoReferenced);
                EditorGUILayout.PropertyField(m_OverrideReferences, Styles.overrideReferences);
                EditorGUILayout.PropertyField(m_NoEngineReferences, Styles.noEngineReferences);

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(Styles.defineConstraints, EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                if (m_DefineConstraints.serializedProperty.arraySize > 0)
                {
                    var defineConstraintsCompatible = true;

                    var defines = CompilationPipeline.GetDefinesFromAssemblyName(m_AssemblyName.stringValue);

                    if (defines != null)
                    {
                        for (var i = 0; i < m_DefineConstraints.serializedProperty.arraySize && defineConstraintsCompatible; ++i)
                        {
                            var defineConstraint = m_DefineConstraints.serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue;

                            if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible)
                            {
                                defineConstraintsCompatible = false;
                            }
                        }

                        var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect());
                        constraintValidityRect.x += constraintValidityRect.width - 23;
                        var image   = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint;
                        var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible);
                        var content = new GUIContent(image, tooltip);

                        constraintValidityRect.width  = Styles.kValidityIconWidth;
                        constraintValidityRect.height = Styles.kValidityIconHeight;
                        EditorGUI.LabelField(constraintValidityRect, content);
                    }
                }

                m_DefineConstraints.DoLayoutList();

                GUILayout.Label(Styles.references, EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_UseGUIDs, Styles.useGUIDs);
                EditorGUILayout.EndVertical();

                m_ReferencesList.DoLayoutList();

                if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).references != null && ((AssemblyDefinitionState)data).references.Any(x => x.asset == null)))
                {
                    EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                }

                if (m_OverrideReferences.boolValue && !m_OverrideReferences.hasMultipleDifferentValues)
                {
                    GUILayout.Label(Styles.precompiledReferences, EditorStyles.boldLabel);

                    UpdatePrecompiledReferenceListEntry();
                    m_PrecompiledReferencesList.DoLayoutList();

                    if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).precompiledReferences.Any(x => string.IsNullOrEmpty(x.path) && !string.IsNullOrEmpty(x.name))))
                    {
                        EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                    }
                }

                GUILayout.Label(Styles.platforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);

                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUILayout.PropertyField(m_CompatibleWithAnyPlatform, Styles.anyPlatform);
                    if (change.changed)
                    {
                        // Invert state include/exclude compatibility of states that have the opposite compatibility,
                        // so all states are either include or exclude.
                        var compatibleWithAny = m_CompatibleWithAnyPlatform.boolValue;
                        var needToSwap        = extraDataTargets.Cast <AssemblyDefinitionState>().Where(p => p.compatibleWithAnyPlatform != compatibleWithAny).ToList();
                        extraDataSerializedObject.ApplyModifiedProperties();
                        foreach (var state in needToSwap)
                        {
                            InversePlatformCompatibility(state);
                        }

                        extraDataSerializedObject.Update();
                    }
                }

                if (!m_CompatibleWithAnyPlatform.hasMultipleDifferentValues)
                {
                    GUILayout.Label(m_CompatibleWithAnyPlatform.boolValue ? Styles.excludePlatforms : Styles.includePlatforms, EditorStyles.boldLabel);

                    for (int i = 0; i < platforms.Length; ++i)
                    {
                        SerializedProperty property;
                        if (i >= m_PlatformCompatibility.arraySize)
                        {
                            m_PlatformCompatibility.arraySize++;
                            property           = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                            property.boolValue = false;
                        }
                        else
                        {
                            property = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                        }

                        EditorGUILayout.PropertyField(property, new GUIContent(platforms[i].DisplayName));
                    }

                    EditorGUILayout.Space();

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(Styles.selectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = true;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    if (GUILayout.Button(Styles.deselectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = false;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label(Styles.versionDefines, EditorStyles.boldLabel);
                m_VersionDefineList.DoLayoutList();
                EditorGUILayout.EndVertical();
            }

            extraDataSerializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }
Пример #22
0
        public override void OnPreviewSettings()
        {
            // TextureInspector code is reused for RenderTexture and Cubemap inspectors.
            // Make sure we can handle the situation where target is just a Texture and
            // not a Texture2D. It's also used for large popups for mini texture fields,
            // and while it's being shown the actual texture object might disappear --
            // make sure to handle null targets.
            Texture tex = target as Texture;

            bool alphaOnly            = true;
            bool hasAlpha             = false;
            bool needsExposureControl = false;
            int  mipCount             = 1;

            foreach (Texture t in targets)
            {
                if (t == null) // texture might have disappeared while we're showing this in a preview popup
                {
                    continue;
                }

                mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t));

                TextureUsageMode mode = TextureUtil.GetUsageMode(t);

                if (!GraphicsFormatUtility.IsAlphaOnlyFormat(t.graphicsFormat))
                {
                    alphaOnly = false;
                }

                if (GraphicsFormatUtility.HasAlphaChannel(t.graphicsFormat))
                {
                    if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha
                    {
                        hasAlpha = true;
                    }
                }

                // 3D texture previewer doesn't support an exposure value.
                if (t.dimension != TextureDimension.Tex3D && NeedsExposureControl(t))
                {
                    needsExposureControl = true;
                }
            }

            if (needsExposureControl)
            {
                OnExposureSlider();
            }

            if (IsCubemap())
            {
                m_CubemapPreview.OnPreviewSettings(targets, mipCount, alphaOnly, hasAlpha);
                return;
            }

            if (IsTexture3D())
            {
                m_Texture3DPreview.OnPreviewSettings(targets);
                return;
            }

            if (IsTexture2DArray() && !SystemInfo.supports2DArrayTextures)
            {
                return;
            }

            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }

            List <PreviewMode> previewCandidates = new List <PreviewMode>(5);

            previewCandidates.Add(PreviewMode.RGB);
            previewCandidates.Add(PreviewMode.R);
            previewCandidates.Add(PreviewMode.G);
            previewCandidates.Add(PreviewMode.B);
            previewCandidates.Add(PreviewMode.A);

            if (alphaOnly)
            {
                previewCandidates.Clear();
                previewCandidates.Add(PreviewMode.A);
                m_PreviewMode = PreviewMode.A;
            }
            else if (!hasAlpha)
            {
                previewCandidates.Remove(PreviewMode.A);
            }

            if (previewCandidates.Count > 1 && tex != null && !IsNormalMap(tex))
            {
                int selectedIndex = previewCandidates.IndexOf(m_PreviewMode);
                if (selectedIndex == -1)
                {
                    selectedIndex = 0;
                }

                if (previewCandidates.Contains(PreviewMode.RGB))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.RGB, s_Styles.previewButtonContents[0], s_Styles.toolbarButton)
                        ? PreviewMode.RGB
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.R))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.R, s_Styles.previewButtonContents[1], s_Styles.toolbarButton)
                        ? PreviewMode.R
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.G))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.G, s_Styles.previewButtonContents[2], s_Styles.toolbarButton)
                        ? PreviewMode.G
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.B))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.B, s_Styles.previewButtonContents[3], s_Styles.toolbarButton)
                        ? PreviewMode.B
                        : m_PreviewMode;
                }
                if (previewCandidates.Contains(PreviewMode.A))
                {
                    m_PreviewMode = GUILayout.Toggle(m_PreviewMode == PreviewMode.A, s_Styles.previewButtonContents[4], s_Styles.toolbarButton)
                        ? PreviewMode.A
                        : m_PreviewMode;
                }
            }

            if (IsTexture2DArray())
            {
                m_Texture2DArrayPreview.OnPreviewSettings(tex);
            }

            if (mipCount > 1)
            {
                GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel);
                GUI.changed = false;
                m_MipLevel  = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, s_Styles.previewSlider, s_Styles.previewSliderThumb, GUILayout.MaxWidth(64)));

                //For now, we don't have mipmaps smaller than the tile size when using VT.
                if (EditorGUI.UseVTMaterial(tex))
                {
                    int numMipsOfTile = (int)Mathf.Log(VirtualTexturing.EditorHelpers.tileSize, 2) + 1;
                    m_MipLevel = Mathf.Min(m_MipLevel, Mathf.Max(mipCount - numMipsOfTile, 0));
                }

                GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel);
            }
        }
Пример #23
0
        internal void OnGUI()
        {
            if (m_Styles == null)
            {
                m_Styles = new Styles();
            }
            if ((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Escape))
            {
                this.CloseWindow();
            }
            Texture2D iconForObject = EditorGUIUtility.GetIconForObject(this.m_TargetObject);
            bool      isLabelIcon   = false;

            if (Event.current.type == EventType.Repaint)
            {
                iconForObject = this.ConvertLargeIconToSmallIcon(iconForObject, ref isLabelIcon);
            }
            Event     current = Event.current;
            EventType type    = current.type;

            GUI.BeginGroup(new Rect(0f, 0f, base.position.width, base.position.height), m_Styles.background);
            this.DoTopSection(iconForObject != null);
            GUILayout.Space(22f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(1f);
            GUI.enabled = false;
            GUILayout.Label(string.Empty, m_Styles.seperator, new GUILayoutOption[0]);
            GUI.enabled = true;
            GUILayout.Space(1f);
            GUILayout.EndHorizontal();
            GUILayout.Space(3f);
            if (this.m_ShowLabelIcons)
            {
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int k = 0; k < (this.m_LabelIcons.Length / 2); k++)
                {
                    this.DoButton(this.m_LabelIcons[k], iconForObject, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(6f);
                for (int m = this.m_LabelIcons.Length / 2; m < this.m_LabelIcons.Length; m++)
                {
                    this.DoButton(this.m_LabelIcons[m], iconForObject, true);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(1f);
                GUI.enabled = false;
                GUILayout.Label(string.Empty, m_Styles.seperator, new GUILayoutOption[0]);
                GUI.enabled = true;
                GUILayout.Space(1f);
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int i = 0; i < (this.m_SmallIcons.Length / 2); i++)
            {
                this.DoButton(this.m_SmallIcons[i], iconForObject, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(9f);
            for (int j = this.m_SmallIcons.Length / 2; j < this.m_SmallIcons.Length; j++)
            {
                this.DoButton(this.m_SmallIcons[j], iconForObject, false);
            }
            GUILayout.Space(3f);
            GUILayout.EndHorizontal();
            GUILayout.Space(6f);
            GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
            bool flag2     = false;
            int  controlID = GUIUtility.GetControlID(s_HashIconSelector, FocusType.Keyboard);

            if (GUILayout.Button(EditorGUIUtility.TempContent("Other..."), new GUILayoutOption[0]))
            {
                GUIUtility.keyboardControl = controlID;
                flag2 = true;
            }
            GUI.backgroundColor = new Color(1f, 1f, 1f, 1f);
            GUI.EndGroup();
            if (flag2)
            {
                ObjectSelector.get.Show(this.m_TargetObject, typeof(Texture2D), null, false);
                ObjectSelector.get.objectSelectorID = controlID;
                GUI.backgroundColor = new Color(1f, 1f, 1f, 0.7f);
                current.Use();
                GUIUtility.ExitGUI();
            }
            EventType type2 = type;

            if ((type2 == EventType.ExecuteCommand) && (((current.commandName == "ObjectSelectorUpdated") && (ObjectSelector.get.objectSelectorID == controlID)) && (GUIUtility.keyboardControl == controlID)))
            {
                Texture2D currentObject = ObjectSelector.GetCurrentObject() as Texture2D;
                EditorGUIUtility.SetIconForObject(this.m_TargetObject, currentObject);
                GUI.changed = true;
                current.Use();
            }
        }
        public override void OnPreviewSettings()
        {
            if (IsCubemap())
            {
                m_CubemapPreview.OnPreviewSettings(targets);
                return;
            }


            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }


            // TextureInspector code is reused for RenderTexture and Cubemap inspectors.
            // Make sure we can handle the situation where target is just a Texture and
            // not a Texture2D. It's also used for large popups for mini texture fields,
            // and while it's being shown the actual texture object might disappear --
            // make sure to handle null targets.
            Texture tex       = target as Texture;
            bool    showMode  = true;
            bool    alphaOnly = false;
            bool    hasAlpha  = true;
            int     mipCount  = 1;

            if (target is Texture2D)
            {
                alphaOnly = true;
                hasAlpha  = false;
            }

            foreach (Texture t in targets)
            {
                if (t == null) // texture might have disappeared while we're showing this in a preview popup
                {
                    continue;
                }
                TextureFormat format      = 0;
                bool          checkFormat = false;
                if (t is Texture2D)
                {
                    format      = (t as Texture2D).format;
                    checkFormat = true;
                }

                if (checkFormat)
                {
                    if (!TextureUtil.IsAlphaOnlyTextureFormat(format))
                    {
                        alphaOnly = false;
                    }
                    if (TextureUtil.HasAlphaTextureFormat(format))
                    {
                        TextureUsageMode mode = TextureUtil.GetUsageMode(t);
                        if (mode == TextureUsageMode.Default) // all other texture usage modes don't displayable alpha
                        {
                            hasAlpha = true;
                        }
                    }
                }

                mipCount = Mathf.Max(mipCount, TextureUtil.GetMipmapCount(t));
            }

            if (alphaOnly)
            {
                m_ShowAlpha = true;
                showMode    = false;
            }
            else if (!hasAlpha)
            {
                m_ShowAlpha = false;
                showMode    = false;
            }

            if (showMode && tex != null && !IsNormalMap(tex))
            {
                m_ShowAlpha = GUILayout.Toggle(m_ShowAlpha, m_ShowAlpha ? s_Styles.alphaIcon : s_Styles.RGBIcon, s_Styles.previewButton);
            }

            if (mipCount > 1)
            {
                GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel);
                GUI.changed = false;
                m_MipLevel  = Mathf.Round(GUILayout.HorizontalSlider(m_MipLevel, mipCount - 1, 0, s_Styles.previewSlider, s_Styles.previewSliderThumb, GUILayout.MaxWidth(64)));
                GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel);
            }
        }
Пример #25
0
 public override void OnPreviewSettings()
 {
     if (this.IsCubemap())
     {
         this.m_CubemapPreview.OnPreviewSettings(base.targets);
     }
     else
     {
         if (s_Styles == null)
         {
             s_Styles = new Styles();
         }
         Texture target = this.target as Texture;
         bool    flag   = true;
         bool    flag2  = false;
         bool    flag3  = true;
         int     a      = 1;
         if ((this.target is Texture2D) || (this.target is ProceduralTexture))
         {
             flag2 = true;
             flag3 = false;
         }
         foreach (Texture texture2 in base.targets)
         {
             TextureFormat format = (TextureFormat)0;
             bool          flag4  = false;
             if (texture2 is Texture2D)
             {
                 format = (texture2 as Texture2D).format;
                 flag4  = true;
             }
             else if (texture2 is ProceduralTexture)
             {
                 format = (texture2 as ProceduralTexture).format;
                 flag4  = true;
             }
             if (flag4)
             {
                 a = Mathf.Max(a, TextureUtil.CountMipmaps(texture2));
                 if (!TextureUtil.IsAlphaOnlyTextureFormat(format))
                 {
                     flag2 = false;
                 }
                 if (TextureUtil.HasAlphaTextureFormat(format) && (TextureUtil.GetUsageMode(texture2) == TextureUsageMode.Default))
                 {
                     flag3 = true;
                 }
             }
         }
         if (flag2)
         {
             this.m_ShowAlpha = true;
             flag             = false;
         }
         else if (!flag3)
         {
             this.m_ShowAlpha = false;
             flag             = false;
         }
         if (flag && !IsNormalMap(target))
         {
             this.m_ShowAlpha = GUILayout.Toggle(this.m_ShowAlpha, !this.m_ShowAlpha ? s_Styles.RGBIcon : s_Styles.alphaIcon, s_Styles.previewButton, new GUILayoutOption[0]);
         }
         GUI.enabled = a != 1;
         GUILayout.Box(s_Styles.smallZoom, s_Styles.previewLabel, new GUILayoutOption[0]);
         GUI.changed = false;
         GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(64f) };
         this.m_MipLevel = Mathf.Round(GUILayout.HorizontalSlider(this.m_MipLevel, (float)(a - 1), 0f, s_Styles.previewSlider, s_Styles.previewSliderThumb, options));
         GUILayout.Box(s_Styles.largeZoom, s_Styles.previewLabel, new GUILayoutOption[0]);
         GUI.enabled = true;
     }
 }
        void Draw(Rect rect)
        {
            Styles.Init();

            var settings = m_SceneView.cameraSettings;

            m_Scroll = GUILayout.BeginScrollView(m_Scroll);

            GUILayout.BeginVertical(Styles.settingsArea);
            EditorGUI.BeginChangeCheck();

            GUILayout.Space(k_HeaderSpacing);

            GUILayout.BeginHorizontal();
            GUILayout.Label(EditorGUIUtility.TrTextContent("Scene Camera"), EditorStyles.boldLabel);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(EditorGUI.GUIContents.titleSettingsIcon, EditorStyles.iconButton))
            {
                ShowContextMenu();
            }
            GUILayout.EndHorizontal();

            EditorGUIUtility.labelWidth = kPrefixLabelWidth;

            // fov isn't applicable in orthographic mode, and orthographic size is controlled by the user zoom
            using (new EditorGUI.DisabledScope(m_SceneView.orthographic))
            {
                settings.fieldOfView = EditorGUILayout.Slider(m_FieldOfView, settings.fieldOfView, k_MinFieldOfView, k_MaxFieldOfView);
            }

            settings.dynamicClip = EditorGUILayout.Toggle(m_DynamicClip, settings.dynamicClip);

            using (new EditorGUI.DisabledScope(settings.dynamicClip))
            {
                float near = settings.nearClip, far = settings.farClip;
                DrawClipPlanesField(EditorGUI.s_ClipingPlanesLabel, ref near, ref far, EditorGUI.kNearFarLabelsWidth);
                settings.SetClipPlanes(near, far);
            }

            settings.occlusionCulling = EditorGUILayout.Toggle(m_OcclusionCulling, settings.occlusionCulling);

            if (EditorGUI.EndChangeCheck())
            {
                m_SceneView.Repaint();
            }

            EditorGUILayout.Space(k_HeaderSpacing);

            GUILayout.Label(EditorGUIUtility.TrTextContent("Navigation"), EditorStyles.boldLabel);

            settings.easingEnabled       = EditorGUILayout.Toggle(m_EasingEnabled, settings.easingEnabled);
            settings.accelerationEnabled = EditorGUILayout.Toggle(m_AccelerationEnabled, settings.accelerationEnabled);

            EditorGUI.BeginChangeCheck();
            float min = settings.speedMin, max = settings.speedMax, speed = settings.RoundSpeedToNearestSignificantDecimal(settings.speed);

            speed = EditorGUILayout.Slider(m_CameraSpeedSliderContent, speed, min, max);
            if (EditorGUI.EndChangeCheck())
            {
                settings.speed = settings.RoundSpeedToNearestSignificantDecimal(speed);
            }

            EditorGUI.BeginChangeCheck();

            m_Vector2Floats[0] = settings.speedMin;
            m_Vector2Floats[1] = settings.speedMax;

            DrawSpeedMinMaxFields();

            if (EditorGUI.EndChangeCheck())
            {
                settings.SetSpeedMinMax(m_Vector2Floats);
            }

            EditorGUIUtility.labelWidth = 0f;

            if (additionalSettingsGui != null)
            {
                EditorGUILayout.Space(k_HeaderSpacing);
                additionalSettingsGui(m_SceneView);
            }

            if (Event.current.type == EventType.Repaint)
            {
                m_WindowSize.y = Math.Min(GUILayoutUtility.GetLastRect().yMax + kContentPadding, kWindowHeight * 3);
            }

            GUILayout.BeginVertical(Styles.settingsArea);
            GUILayout.EndScrollView();
        }
Пример #27
0
        public override void OnGUI(Rect rect)
        {
            if (s_Styles == null)
            {
                s_Styles = new Styles();
            }
            GameViewSize other = base.m_Object as GameViewSize;

            if (other == null)
            {
                Debug.LogError("Invalid object");
            }
            else
            {
                if (this.m_GameViewSize == null)
                {
                    this.m_GameViewSize = new GameViewSize(other);
                }
                bool flag = (this.m_GameViewSize.width > 0) && (this.m_GameViewSize.height > 0);
                GUILayout.Space(3f);
                GUILayout.Label((base.m_MenuType != FlexibleMenuModifyItemUI.MenuType.Add) ? s_Styles.headerEdit : s_Styles.headerAdd, EditorStyles.boldLabel, new GUILayoutOption[0]);
                FlexibleMenu.DrawRect(GUILayoutUtility.GetRect((float)1f, (float)1f), !EditorGUIUtility.isProSkin ? new Color(0.6f, 0.6f, 0.6f, 1.333f) : new Color(0.32f, 0.32f, 0.32f, 1.333f));
                GUILayout.Space(4f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.optionalText, options);
                GUILayout.Space(10f);
                this.m_GameViewSize.baseText = EditorGUILayout.TextField(this.m_GameViewSize.baseText, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.typeName, optionArray2);
                GUILayout.Space(10f);
                this.m_GameViewSize.sizeType = (GameViewSizeType)EditorGUILayout.Popup((int)this.m_GameViewSize.sizeType, s_Styles.typeNames, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width(90f) };
                GUILayout.Label(s_Styles.widthHeightText, optionArray3);
                GUILayout.Space(10f);
                this.m_GameViewSize.width = EditorGUILayout.IntField(this.m_GameViewSize.width, new GUILayoutOption[0]);
                GUILayout.Space(5f);
                this.m_GameViewSize.height = EditorGUILayout.IntField(this.m_GameViewSize.height, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                float pixels    = 10f;
                float cropWidth = rect.width - (2f * pixels);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(pixels);
                GUILayout.FlexibleSpace();
                string displayText = this.m_GameViewSize.displayText;
                using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(displayText)))
                {
                    if (string.IsNullOrEmpty(displayText))
                    {
                        displayText = "Result";
                    }
                    else
                    {
                        displayText = this.GetCroppedText(displayText, cropWidth, EditorStyles.label);
                    }
                    GUILayout.Label(GUIContent.Temp(displayText), EditorStyles.label, new GUILayoutOption[0]);
                }
                GUILayout.FlexibleSpace();
                GUILayout.Space(pixels);
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(10f);
                if (GUILayout.Button(s_Styles.cancel, new GUILayoutOption[0]))
                {
                    base.editorWindow.Close();
                }
                using (new EditorGUI.DisabledScope(!flag))
                {
                    if (GUILayout.Button(s_Styles.ok, new GUILayoutOption[0]))
                    {
                        other.Set(this.m_GameViewSize);
                        base.Accepted();
                        base.editorWindow.Close();
                    }
                }
                GUILayout.Space(10f);
                GUILayout.EndHorizontal();
            }
        }