Пример #1
0
        public static void drawSmallTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool scaleOffset, bool has_panning_field = false)
        {
            Rect thumbnailPos = position;

            thumbnailPos.x += scaleOffset ? 20 : 0;
            editor.TexturePropertyMiniThumbnail(thumbnailPos, prop, label.text, (scaleOffset? "Click here for scale / offset":"") + (label.tooltip != "" ? " | " : "") + label.tooltip);
            if (scaleOffset && DrawingData.currentTexProperty != null)
            {
                //draw dropdown triangle
                thumbnailPos.x += ThryEditor.currentlyDrawing.currentProperty.xOffset * 30;
                if (Event.current.type == EventType.Repaint)
                {
                    EditorStyles.foldout.Draw(thumbnailPos, false, false, DrawingData.currentTexProperty.showScaleOffset, false);
                }
                //test click and draw scale/offset
                if (DrawingData.currentTexProperty.showScaleOffset)
                {
                    ThryEditor.currentlyDrawing.editor.TextureScaleOffsetProperty(prop);
                    if (has_panning_field && ThryEditor.currentlyDrawing.currentProperty.options.reference_property != null)
                    {
                        ThryEditor.ShaderProperty pan_property = ThryEditor.currentlyDrawing.propertyDictionary[ThryEditor.currentlyDrawing.currentProperty.options.reference_property];
                        EditorGUI.indentLevel *= 2;
                        ThryEditor.currentlyDrawing.editor.ShaderProperty(GUILayoutUtility.GetRect(pan_property.content, Styles.Get().vectorPropertyStyle), pan_property.materialProperty, pan_property.content);
                        EditorGUI.indentLevel /= 2;
                    }
                }
                if (ThryEditor.MouseClick && position.Contains(Event.current.mousePosition))
                {
                    DrawingData.currentTexProperty.showScaleOffset = !DrawingData.currentTexProperty.showScaleOffset;
                    editor.Repaint();
                }
            }

            DrawingData.lastGuiObjectRect = position;
        }
        public static void drawSmallTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool hasFoldoutProperties)
        {
            Rect thumbnailPos = position;

            thumbnailPos.x += hasFoldoutProperties ? 20 : 0;
            editor.TexturePropertyMiniThumbnail(thumbnailPos, prop, label.text, (hasFoldoutProperties ? "Click here for extra properties":"") + (label.tooltip != "" ? " | " : "") + label.tooltip);
            if (hasFoldoutProperties && DrawingData.currentTexProperty != null)
            {
                //draw dropdown triangle
                thumbnailPos.x += DrawingData.currentTexProperty.xOffset * 15;
                if (Event.current.type == EventType.Repaint)
                {
                    EditorStyles.foldout.Draw(thumbnailPos, false, false, DrawingData.currentTexProperty.showFoldoutProperties, false);
                }

                if (DrawingData.is_enabled)
                {
                    //test click and draw scale/offset
                    if (DrawingData.currentTexProperty.showFoldoutProperties)
                    {
                        if (DrawingData.currentTexProperty.hasScaleOffset)
                        {
                            ThryEditor.currentlyDrawing.editor.TextureScaleOffsetProperty(prop);
                        }

                        PropertyOptions options = DrawingData.currentTexProperty.options;
                        if (options.reference_properties != null)
                        {
                            foreach (string r_property in options.reference_properties)
                            {
                                ThryEditor.ShaderProperty property = ThryEditor.currentlyDrawing.propertyDictionary[r_property];
                                EditorGUIUtility.labelWidth += EditorGUI.indentLevel * 15;
                                EditorGUI.indentLevel       *= 2;
                                ThryEditor.currentlyDrawing.editor.ShaderProperty(property.materialProperty, property.content);
                                EditorGUI.indentLevel       /= 2;
                                EditorGUIUtility.labelWidth -= EditorGUI.indentLevel * 15;
                            }
                        }
                    }
                    if (ThryEditor.input.MouseClick && position.Contains(Event.current.mousePosition))
                    {
                        DrawingData.currentTexProperty.showFoldoutProperties = !DrawingData.currentTexProperty.showFoldoutProperties;
                        editor.Repaint();
                    }
                }
            }

            DrawingData.lastGuiObjectHeaderRect = position;
            Rect object_rect = new Rect(position);

            object_rect.height            = GUILayoutUtility.GetLastRect().y - object_rect.y + GUILayoutUtility.GetLastRect().height;
            DrawingData.lastGuiObjectRect = object_rect;
        }
Пример #3
0
        public bool Test()
        {
            string comparator = GetComparetor();

            string[] parts = Regex.Split(data, comparator);
            string   obj   = parts[0];
            string   value = parts[parts.Length - 1];

            switch (type)
            {
            case DefineableConditionType.PROPERTY_BOOL:
                ThryEditor.ShaderProperty prop = ThryEditor.currentlyDrawing.propertyDictionary[obj];
                if (prop == null)
                {
                    return(false);
                }
                if (comparator == "##")
                {
                    return(prop.materialProperty.floatValue == 1);
                }
                if (comparator == "==")
                {
                    return("" + prop.materialProperty.floatValue == parts[1]);
                }
                if (comparator == "!=")
                {
                    return("" + prop.materialProperty.floatValue != parts[1]);
                }
                break;

            case DefineableConditionType.EDITOR_VERSION:
                int c_ev = Helper.compareVersions(Config.Get().verion, value);
                if (comparator == "==")
                {
                    return(c_ev == 0);
                }
                if (comparator == "!=")
                {
                    return(c_ev != 0);
                }
                if (comparator == "<")
                {
                    return(c_ev == 1);
                }
                if (comparator == ">")
                {
                    return(c_ev == -1);
                }
                break;

            case DefineableConditionType.VRC_SDK_VERSION:
                int c_vrc = Helper.compareVersions(VRCInterface.Get().installed_sdk_version, value);
                if (comparator == "==")
                {
                    return(c_vrc == 0);
                }
                if (comparator == "!=")
                {
                    return(c_vrc != 0);
                }
                if (comparator == "<")
                {
                    return(c_vrc == 1);
                }
                if (comparator == ">")
                {
                    return(c_vrc == -1);
                }
                break;

            case DefineableConditionType.AND:
                if (condition1 != null && condition2 != null)
                {
                    return(condition1.Test() && condition2.Test());
                }
                break;

            case DefineableConditionType.OR:
                if (condition1 != null && condition2 != null)
                {
                    return(condition1.Test() || condition2.Test());
                }
                break;
            }

            return(true);
        }
        public static void drawStylizedBigTextureProperty(Rect position, MaterialProperty prop, GUIContent label, MaterialEditor editor, bool hasFoldoutProperties, bool skip_drag_and_drop_handling = false)
        {
            position.x     += (EditorGUI.indentLevel) * 15;
            position.width -= (EditorGUI.indentLevel) * 15;
            Rect rect = GUILayoutUtility.GetRect(label, Styles.Get().bigTextureStyle);

            rect.x     += (EditorGUI.indentLevel) * 15;
            rect.width -= (EditorGUI.indentLevel) * 15;
            Rect border = new Rect(rect);

            border.position = new Vector2(border.x, border.y - position.height);
            border.height  += position.height;

            if (DrawingData.currentTexProperty.reference_properties_exist)
            {
                border.height += 8;
                foreach (string r_property in DrawingData.currentTexProperty.options.reference_properties)
                {
                    border.height += editor.GetPropertyHeight(ThryEditor.currentlyDrawing.propertyDictionary[r_property].materialProperty);
                }
            }


            //background
            GUI.DrawTexture(border, Styles.rounded_texture, ScaleMode.StretchToFill, true);
            Rect quad = new Rect(border);

            quad.width = quad.height / 2;
            GUI.DrawTextureWithTexCoords(quad, Styles.rounded_texture, new Rect(0, 0, 0.5f, 1), true);
            quad.x += border.width - quad.width;
            GUI.DrawTextureWithTexCoords(quad, Styles.rounded_texture, new Rect(0.5f, 0, 0.5f, 1), true);

            quad.width  = border.height - 4;
            quad.height = quad.width;
            quad.x      = border.x + border.width - quad.width - 1;
            quad.y     += 2;


            Rect preview_rect_border = new Rect(position);

            preview_rect_border.height = rect.height + position.height - 6;
            preview_rect_border.width  = preview_rect_border.height;
            preview_rect_border.y     += 3;
            preview_rect_border.x     += position.width - preview_rect_border.width - 3;
            Rect preview_rect = new Rect(preview_rect_border);

            preview_rect.height -= 6;
            preview_rect.width  -= 6;
            preview_rect.x      += 3;
            preview_rect.y      += 3;
            if (prop.hasMixedValue)
            {
                Rect mixedRect = new Rect(preview_rect);
                mixedRect.y -= 5;
                mixedRect.x += mixedRect.width / 2 - 4;
                GUI.Label(mixedRect, "_");
            }
            else if (prop.textureValue != null)
            {
                GUI.DrawTexture(preview_rect, prop.textureValue);
            }
            GUI.DrawTexture(preview_rect_border, Texture2D.whiteTexture, ScaleMode.StretchToFill, false, 0, Color.grey, 3, 5);

            //selection button and pinging
            Rect select_rect = new Rect(preview_rect);

            select_rect.height = 12;
            select_rect.y     += preview_rect.height - 12;
            if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == texturePickerWindow)
            {
                prop.textureValue = (Texture)EditorGUIUtility.GetObjectPickerObject();
                ThryEditor.repaint();
            }
            if (Event.current.commandName == "ObjectSelectorClosed" && EditorGUIUtility.GetObjectPickerControlID() == texturePickerWindow)
            {
                texturePickerWindow = -1;
            }
            if (GUI.Button(select_rect, "Select", EditorStyles.miniButton))
            {
                EditorGUIUtility.ShowObjectPicker <Texture>(prop.textureValue, false, "", 0);
                texturePickerWindow = EditorGUIUtility.GetObjectPickerControlID();
            }
            else if (Event.current.type == EventType.MouseDown && preview_rect.Contains(Event.current.mousePosition))
            {
                EditorGUIUtility.PingObject(prop.textureValue);
            }

            if (!skip_drag_and_drop_handling)
            {
                if ((ThryEditor.input.is_drag_drop_event) && preview_rect.Contains(ThryEditor.input.mouse_position) && DragAndDrop.objectReferences[0] is Texture)
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    if (ThryEditor.input.is_drop_event)
                    {
                        DragAndDrop.AcceptDrag();
                        prop.textureValue = (Texture)DragAndDrop.objectReferences[0];
                    }
                }
            }

            //scale offset rect
            if (hasFoldoutProperties)
            {
                if (DrawingData.currentTexProperty.hasScaleOffset)
                {
                    Rect scale_offset_rect = new Rect(position);
                    scale_offset_rect.y     += 37;
                    scale_offset_rect.width -= 2 + preview_rect.width + 10;
                    editor.TextureScaleOffsetProperty(scale_offset_rect, prop);
                }

                PropertyOptions options = DrawingData.currentTexProperty.options;
                if (options.reference_properties != null)
                {
                    foreach (string r_property in options.reference_properties)
                    {
                        ThryEditor.ShaderProperty property = ThryEditor.currentlyDrawing.propertyDictionary[r_property];
                        EditorGUI.indentLevel *= 2;
                        ThryEditor.currentlyDrawing.editor.ShaderProperty(property.materialProperty, property.content);
                        EditorGUI.indentLevel /= 2;
                    }
                }
            }

            Rect label_rect = new Rect(position);

            label_rect.x += 2;
            label_rect.y += 2;
            GUI.Label(label_rect, label);

            GUILayoutUtility.GetRect(0, 5);

            DrawingData.lastGuiObjectHeaderRect = position;
            DrawingData.lastGuiObjectRect       = border;
        }