Exemple #1
0
        private void OnGUIShaderPropTexture(Rect nameRect, Rect flagsRect, Rect valueRect, ShaderTextureInfo t)
        {
            GUI.Label(nameRect, t.name, EditorStyles.miniLabel);
            this.DrawShaderPropertyFlags(flagsRect, t.flags);
            Event current  = Event.current;
            Rect  position = valueRect;

            position.width = position.height;
            if (t.value != null && position.Contains(current.mousePosition))
            {
                GUI.Label(position, GUIContent.Temp(string.Empty, "Ctrl + Click to show preview"));
            }
            if (current.type == EventType.Repaint)
            {
                Rect position2 = valueRect;
                position2.xMin += position.width;
                if (t.value != null)
                {
                    Texture texture = t.value;
                    if (texture.dimension != TextureDimension.Tex2D)
                    {
                        texture = AssetPreview.GetMiniThumbnail(texture);
                    }
                    EditorGUI.DrawPreviewTexture(position, texture);
                }
                GUI.Label(position2, (!(t.value != null)) ? t.textureName : t.value.name);
            }
            else if (current.type == EventType.MouseDown)
            {
                if (valueRect.Contains(current.mousePosition))
                {
                    EditorGUI.PingObjectOrShowPreviewOnClick(t.value, valueRect);
                    current.Use();
                }
            }
        }
Exemple #2
0
 private void DrawShaderProperties(ShaderProperties props)
 {
     this.m_ScrollViewShaderProps = GUILayout.BeginScrollView(this.m_ScrollViewShaderProps, new GUILayoutOption[0]);
     if (props.textures.Count <ShaderTextureInfo>() > 0)
     {
         GUILayout.Label("Textures", EditorStyles.boldLabel, new GUILayoutOption[0]);
         Rect nameRect;
         Rect flagsRect;
         Rect valueRect;
         this.GetPropertyFieldRects(props.textures.Count <ShaderTextureInfo>(), 16f, out nameRect, out flagsRect, out valueRect);
         ShaderTextureInfo[] textures = props.textures;
         for (int i = 0; i < textures.Length; i++)
         {
             ShaderTextureInfo t = textures[i];
             this.OnGUIShaderPropTexture(nameRect, flagsRect, valueRect, t);
             nameRect.y  += nameRect.height;
             flagsRect.y += flagsRect.height;
             valueRect.y += valueRect.height;
         }
     }
     if (props.floats.Count <ShaderFloatInfo>() > 0)
     {
         GUILayout.Label("Floats", EditorStyles.boldLabel, new GUILayoutOption[0]);
         Rect nameRect;
         Rect flagsRect;
         Rect valueRect;
         this.GetPropertyFieldRects(props.floats.Count <ShaderFloatInfo>(), 16f, out nameRect, out flagsRect, out valueRect);
         ShaderFloatInfo[] floats = props.floats;
         for (int j = 0; j < floats.Length; j++)
         {
             ShaderFloatInfo t2 = floats[j];
             this.OnGUIShaderPropFloat(nameRect, flagsRect, valueRect, t2);
             nameRect.y  += nameRect.height;
             flagsRect.y += flagsRect.height;
             valueRect.y += valueRect.height;
         }
     }
     if (props.vectors.Count <ShaderVectorInfo>() > 0)
     {
         GUILayout.Label("Vectors", EditorStyles.boldLabel, new GUILayoutOption[0]);
         Rect nameRect;
         Rect flagsRect;
         Rect valueRect;
         this.GetPropertyFieldRects(props.vectors.Count <ShaderVectorInfo>(), 16f, out nameRect, out flagsRect, out valueRect);
         ShaderVectorInfo[] vectors = props.vectors;
         for (int k = 0; k < vectors.Length; k++)
         {
             ShaderVectorInfo t3 = vectors[k];
             this.OnGUIShaderPropVector4(nameRect, flagsRect, valueRect, t3);
             nameRect.y  += nameRect.height;
             flagsRect.y += flagsRect.height;
             valueRect.y += valueRect.height;
         }
     }
     if (props.matrices.Count <ShaderMatrixInfo>() > 0)
     {
         GUILayout.Label("Matrices", EditorStyles.boldLabel, new GUILayoutOption[0]);
         Rect nameRect;
         Rect flagsRect;
         Rect valueRect;
         this.GetPropertyFieldRects(props.matrices.Count <ShaderMatrixInfo>(), 48f, out nameRect, out flagsRect, out valueRect);
         ShaderMatrixInfo[] matrices = props.matrices;
         for (int l = 0; l < matrices.Length; l++)
         {
             ShaderMatrixInfo t4 = matrices[l];
             this.OnGUIShaderPropMatrix(nameRect, flagsRect, valueRect, t4);
             nameRect.y  += nameRect.height;
             flagsRect.y += flagsRect.height;
             valueRect.y += valueRect.height;
         }
     }
     if (props.buffers.Count <ShaderBufferInfo>() > 0)
     {
         GUILayout.Label("Buffers", EditorStyles.boldLabel, new GUILayoutOption[0]);
         Rect nameRect;
         Rect flagsRect;
         Rect valueRect;
         this.GetPropertyFieldRects(props.buffers.Count <ShaderBufferInfo>(), 16f, out nameRect, out flagsRect, out valueRect);
         ShaderBufferInfo[] buffers = props.buffers;
         for (int m = 0; m < buffers.Length; m++)
         {
             ShaderBufferInfo t5 = buffers[m];
             this.OnGUIShaderPropBuffer(nameRect, flagsRect, valueRect, t5);
             nameRect.y  += nameRect.height;
             flagsRect.y += flagsRect.height;
             valueRect.y += valueRect.height;
         }
     }
     GUILayout.EndScrollView();
 }
Exemple #3
0
 private void OnGUIShaderPropTexture(Rect nameRect, Rect flagsRect, Rect valueRect, ShaderTextureInfo t)
 {
     GUI.Label(nameRect, t.name, EditorStyles.miniLabel);
     this.DrawShaderPropertyFlags(flagsRect, t.flags);
     if (Event.current.type == EventType.Repaint)
     {
         Rect position1 = valueRect;
         position1.width = position1.height;
         Rect position2 = valueRect;
         position2.xMin += position1.width;
         if ((UnityEngine.Object)t.value != (UnityEngine.Object)null)
         {
             EditorGUI.DrawPreviewTexture(position1, t.value);
         }
         GUI.Label(position2, !((UnityEngine.Object)t.value != (UnityEngine.Object)null) ? t.textureName : t.value.name);
     }
     else
     {
         if (Event.current.type != EventType.MouseDown || !valueRect.Contains(Event.current.mousePosition))
         {
             return;
         }
         EditorGUIUtility.PingObject((UnityEngine.Object)t.value);
         Event.current.Use();
     }
 }