Ejemplo n.º 1
0
 public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate)
 {
     if (propertyDrawer is ShaderGUIOverridePropertyDrawer shaderGuiOverridePropertyDrawer)
     {
         shaderGuiOverridePropertyDrawer.GetPropertyData(node);
     }
 }
Ejemplo n.º 2
0
 void DrawInspectable(
     VisualElement outputVisualElement,
     IInspectable inspectable,
     IPropertyDrawer propertyDrawerToUse = null)
 {
     InspectorUtils.GatherInspectorContent(m_PropertyDrawerList, outputVisualElement, inspectable, TriggerInspectorUpdate, propertyDrawerToUse);
 }
Ejemplo n.º 3
0
        public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate)
        {
            if (propertyDrawer is ShaderInputPropertyDrawer shaderInputPropertyDrawer)
            {
                var propNode = node as PropertyNode;
                var graph    = node.owner as GraphData;

                shaderInputPropertyDrawer.GetPropertyData(
                    graph.isSubGraph,
                    graph,
                    this.ChangeExposedField,
                    this.ChangeDisplayNameField,
                    this.ChangeReferenceNameField,
                    () => graph.ValidateGraph(),
                    () => graph.OnKeywordChanged(),
                    this.ChangePropertyValue,
                    this.RegisterPropertyChangeUndo,
                    this.MarkNodesAsDirty);

                this.m_propertyViewUpdateTrigger = inspectorUpdateDelegate;
                this.m_resetReferenceNameTrigger = shaderInputPropertyDrawer._resetReferenceNameCallback;
            }

            UpdateReferenceNameResetMenu();
        }
Ejemplo n.º 4
0
        internal static void GatherInspectorContent(
            List <Type> propertyDrawerList,
            VisualElement outputVisualElement,
            IInspectable inspectable,
            Action propertyChangeCallback,
            List <IPropertyDrawer> allPropertyDrawerInstances,
            IPropertyDrawer propertyDrawerToUse = null)
        {
            var dataObject = inspectable.GetObjectToInspect();

            if (dataObject == null)
            {
                throw new NullReferenceException("DataObject returned by Inspectable is null!");
            }

            var properties = inspectable.GetType().GetProperties(BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (properties == null)
            {
                throw new NullReferenceException("PropertyInfos returned by Inspectable is null!");
            }

            foreach (var propertyInfo in properties)
            {
                var attribute = propertyInfo.GetCustomAttribute <InspectableAttribute>();
                if (attribute == null)
                {
                    continue;
                }

                var propertyType = propertyInfo.GetGetMethod(true).Invoke(inspectable, new object[] { }).GetType();

                var propertyDrawerInstance = propertyDrawerToUse;
                if (propertyDrawerInstance == null)
                {
                    if (IsPropertyTypeHandled(propertyDrawerList, propertyType, out var propertyDrawerTypeToUse))
                    {
                        propertyDrawerInstance = (IPropertyDrawer)Activator.CreateInstance(propertyDrawerTypeToUse);
                    }
                }

                if (propertyDrawerInstance != null)
                {
                    // Assign the inspector update delegate so any property drawer can trigger an inspector update if it needs it
                    propertyDrawerInstance.inspectorUpdateDelegate = propertyChangeCallback;
                    // Supply any required data to this particular kind of property drawer
                    inspectable.SupplyDataToPropertyDrawer(propertyDrawerInstance, propertyChangeCallback);
                    var propertyGUI = propertyDrawerInstance.DrawProperty(propertyInfo, dataObject, attribute);
                    outputVisualElement.Add(propertyGUI);
                    if (allPropertyDrawerInstances != null)
                    {
                        allPropertyDrawerInstances.Add(propertyDrawerInstance);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate)
        {
            if (propertyDrawer is ShaderInputPropertyDrawer shaderInputPropertyDrawer)
            {
                shaderInputPropertyDrawer.GetPropertyData(m_Graph.isSubGraph,
                                                          ChangeExposedField,
                                                          ChangeReferenceNameField,
                                                          () => m_Graph.ValidateGraph(),
                                                          () => m_Graph.OnKeywordChanged(),
                                                          ChangePropertyValue,
                                                          RegisterPropertyChangeUndo,
                                                          MarkNodesAsDirty);

                m_propertyViewUpdateTrigger = inspectorUpdateDelegate;
                m_resetReferenceNameTrigger = shaderInputPropertyDrawer._resetReferenceNameCallback;
            }
        }
Ejemplo n.º 6
0
        public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate)
        {
            if (propertyDrawer is ShaderInputPropertyDrawer shaderInputPropertyDrawer)
            {
                shaderInputPropertyDrawer.GetPropertyData(
                    m_Graph.isSubGraph,
                    m_Graph,
                    ChangeExposedField,
                    () => m_Graph.ValidateGraph(),
                    () => m_Graph.OnKeywordChanged(),
                    ChangePropertyValue,
                    RegisterPropertyChangeUndo,
                    MarkNodesAsDirty);

                m_inspectorUpdateTrigger   = inspectorUpdateDelegate;
                m_ResetReferenceNameAction = shaderInputPropertyDrawer.ResetReferenceName;

                this.RegisterCallback <DetachFromPanelEvent>(evt => m_inspectorUpdateTrigger());
            }
        }
Ejemplo n.º 7
0
        public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate)
        {
            if (propertyDrawer is ShaderInputPropertyDrawer shaderInputPropertyDrawer)
            {
                var propNode = node as PropertyNode;
                var graph    = node.owner as GraphData;

                shaderInputPropertyDrawer.GetPropertyData(
                    graph.isSubGraph,
                    graph,
                    this.ChangeExposedField,
                    () => graph.ValidateGraph(),
                    () => graph.OnKeywordChanged(),
                    () => graph.OnDropdownChanged(),
                    this.ChangePropertyValue,
                    this.MarkNodesAsDirty);

                this.m_propertyViewUpdateTrigger = inspectorUpdateDelegate;
                this.m_ResetReferenceNameAction  = shaderInputPropertyDrawer.ResetReferenceName;
            }
        }
Ejemplo n.º 8
0
        public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate)
        {
            if (propertyDrawer is ShaderInputPropertyDrawer shaderInputPropertyDrawer)
            {
                var propNode = node as PropertyNode;
                var graph    = node.owner as GraphData;

                var shaderInputViewModel = new ShaderInputViewModel()
                {
                    model                    = property,
                    parentView               = null,
                    isSubGraph               = graph.isSubGraph,
                    isInputExposed           = property.isExposed,
                    inputName                = property.displayName,
                    inputTypeName            = property.GetPropertyTypeString(),
                    requestModelChangeAction = this.RequestModelChange
                };
                shaderInputPropertyDrawer.GetViewModel(shaderInputViewModel, node.owner, this.MarkNodesAsDirty);

                this.m_propertyViewUpdateTrigger = inspectorUpdateDelegate;
                this.m_ResetReferenceNameAction  = shaderInputPropertyDrawer.ResetReferenceName;
            }
        }
Ejemplo n.º 9
0
        public void SupplyDataToPropertyDrawer(IPropertyDrawer propertyDrawer, Action inspectorUpdateDelegate, Action <InspectorUpdateSource> scopedInspectorUpdateDelegate = null)
        {
            if (propertyDrawer is ShaderInputPropertyDrawer shaderInputPropertyDrawer)
            {
                shaderInputPropertyDrawer.GetPropertyData(
                    m_Graph.isSubGraph,
                    m_Graph,
                    ChangeExposedField,
                    ChangeDisplayNameField,
                    ChangeReferenceNameField,
                    () => m_Graph.ValidateGraph(),
                    () => m_Graph.OnKeywordChanged(),
                    ChangePropertyValue,
                    RegisterPropertyChangeUndo,
                    MarkNodesAsDirty);

                m_inspectorUpdateTrigger    = inspectorUpdateDelegate;
                m_resetReferenceNameTrigger = shaderInputPropertyDrawer._resetReferenceNameCallback;

                this.RegisterCallback <DetachFromPanelEvent>(evt => m_inspectorUpdateTrigger());
            }

            UpdateRightClickMenu();
        }