Esempio n. 1
0
 public static void RegisterEditor(MaterialEditor editor, MixtureNodeView nodeView, MixtureGraph graph)
 {
     if (mixtureDrawerInfos.ContainsKey(editor))
     {
         mixtureDrawerInfos[editor].graph    = graph;
         mixtureDrawerInfos[editor].nodeView = nodeView;
     }
     else
     {
         mixtureDrawerInfos[editor] = new MixtureDrawerInfo {
             graph = graph, nodeView = nodeView
         }
     };
 }
Esempio n. 2
0
        public NodeTexturePreview(MixtureNodeView view)
        {
            nodeView    = view;
            graphView   = nodeView.owner as MixtureGraphView;
            previewRoot = Resources.Load <VisualTreeAsset>("UI Blocks/Preview").CloneTree();
            Add(previewRoot);

            // Load additional resources:
            arrowUp   = Resources.Load <Texture2D>("Collapse-Down");
            arrowDown = Resources.Load <Texture2D>("Collapse-Up");

            // Init all preview components:
            previewContainer = previewRoot.Q("PreviewContainer");
            rgb = previewRoot.Q("ToggleRGB") as Toggle;
            r   = previewRoot.Q("ToggleR") as Toggle;
            g   = previewRoot.Q("ToggleG") as Toggle;
            b   = previewRoot.Q("ToggleB") as Toggle;
            a   = previewRoot.Q("ToggleA") as Toggle;

            mipmapSlider      = previewRoot.Q("MipMapSlider") as SliderInt;
            mipmapInputs      = previewRoot.Q("MipMapInput") as VisualElement;
            currentMipIndex   = previewRoot.Q("MipMapNumberText") as Label;
            sliceInputs       = previewRoot.Q("SliceInputs");
            sliceSlider       = previewRoot.Q("SliceSlider") as SliderInt;
            currentSliceIndex = previewRoot.Q("SliceNumber") as IntegerField;
            imageInfo         = previewRoot.Q("ImageInfo");
            textureInfo       = previewRoot.Q("ImageInfoText") as Label;
            collapseButton    = previewRoot.Q("PreviewFoldout") as Button;
            previewImage      = previewRoot.Q("PreviewImage");

            previewImage.style.width  = 200;
            previewImage.style.height = 200;

            previewImage.Add(new IMGUIContainer(DrawPreviewImage));

            // TODO: determine image size rect to fit the node

            collapseButton.clicked += PreviewColapse;

            // TODO: all events, preview shader ect...
        }
Esempio n. 3
0
 protected virtual void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
 {
 }
Esempio n. 4
0
 public static void RegisterEditor(MaterialEditor editor, MixtureNodeView nodeView, MixtureGraph graph)
 {
     mixtureDrawerInfos[editor] = new MixtureDrawerInfo {
         graph = graph, nodeView = nodeView
     };
 }
Esempio n. 5
0
 protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
 {
     prop.floatValue = EditorGUI.Slider(position, prop.displayName, prop.floatValue, prop.rangeLimits.x, prop.rangeLimits.y);
 }
        protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
        {
            EditorGUI.BeginChangeCheck();
            int value = (int)(Blend)EditorGUI.EnumPopup(position, label, (Blend)(int)prop.floatValue);

            if (EditorGUI.EndChangeCheck())
            {
                prop.floatValue = (float)value;
            }
        }
Esempio n. 7
0
        protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
        {
            //Enum(ScaleBias,0,BiasScale,1,Scale,2,Bias,3,TwiceMinusOne,4,HalvePlusHalf,5)

            int value = EditorGUI.IntPopup(position, label, (int)prop.floatValue, displayedOptions, optionValues);

            if (GUI.changed)
            {
                prop.floatValue = (float)value;
            }
        }
Esempio n. 8
0
        protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
        {
            EditorGUIUtility.wideMode = true;
            Vector3 value = EditorGUI.Vector3Field(position, prop.displayName, prop.vectorValue);

            if (GUI.changed)
            {
                prop.vectorValue = new Vector4(value.x, value.y, value.z, 0);
            }
        }
Esempio n. 9
0
 // Draw the property inside the given rect
 protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
 {
     tooltip = label;
 }
Esempio n. 10
0
        protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
        {
            if (!visibleInInspector)
            {
                return;
            }

            if (!(prop.textureValue is Texture) && prop.textureValue != null)
            {
                prop.textureValue = null;
            }

            Texture value = (Texture)EditorGUI.ObjectField(position, prop.displayName, prop.textureValue, typeof(Texture), false);

            if (GUI.changed)
            {
                prop.textureValue = value;
            }
        }
Esempio n. 11
0
        protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
        {
            //Enum(Brightness (Gradient),0,Alpha (Curve),1,Brightness (Curve),2,Saturation (Curve),3,Hue (Curve),4,Red (Curve),5,Green (Curve),6,Blue (Curve),7)

            int value = EditorGUI.IntPopup(position, label, (int)prop.floatValue, displayedOptions, optionValues);

            if (GUI.changed)
            {
                prop.floatValue = (float)value;
            }
        }
Esempio n. 12
0
        protected override void DrawerGUI(Rect position, MaterialProperty prop, string label, MaterialEditor editor, MixtureGraph graph, MixtureNodeView nodeView)
        {
            //[Enum(Red,0,Green,1,Blue,2,Alpha,3)]

            int value = EditorGUI.IntPopup(position, label, (int)prop.floatValue, displayedOptions, optionValues);

            if (GUI.changed)
            {
                prop.floatValue = (float)value;
            }
        }