Beispiel #1
0
        public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo)
        {
            // show the target default surface properties
            var builtInTarget = (target as BuiltInTarget);

            builtInTarget?.GetDefaultSurfacePropertiesGUI(ref context, onChange, registerUndo);
        }
Beispiel #2
0
        public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo)
        {
            var universalTarget = (target as UniversalTarget);

            universalTarget.AddDefaultMaterialOverrideGUI(ref context, onChange, registerUndo);
            universalTarget.AddDefaultSurfacePropertiesGUI(ref context, onChange, registerUndo, showReceiveShadows: false);
        }
Beispiel #3
0
 internal void Initialize(TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo,
                          SystemData systemData, BuiltinData builtinData, LightingData lightingData)
 {
     this.context      = context;
     this.onChange     = onChange;
     this.registerUndo = registerUndo;
     this.systemData   = systemData;
     this.builtinData  = builtinData;
     this.lightingData = lightingData;
 }
        public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo)
        {
            context.AddProperty("Blending Mode", new UnityEngine.UIElements.EnumField(AlphaMode.Alpha)
            {
                value = target.alphaMode
            }, (evt) =>
            {
                if (Equals(target.alphaMode, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Blend");
                target.alphaMode = (AlphaMode)evt.newValue;
                onChange();
            });
        }
        VisualElement GetSettings(GraphData graphData, Action onChange)
        {
            var element = new VisualElement()
            {
                name = "graphSettings"
            };

            if (graphData.isSubGraph)
            {
                return(element);
            }

            void RegisterActionToUndo(string actionName)
            {
                graphData.owner.RegisterCompleteObjectUndo(actionName);
            }

            // Add Label
            var targetSettingsLabel = new Label("Target Settings");

            targetSettingsLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
            element.Add(new PropertyRow(targetSettingsLabel));

            var targetNameList = graphData.validTargets.Select(x => x.displayName);

            element.Add(new PropertyRow(new Label("Targets")), (row) =>
            {
                row.Add(new IMGUIContainer(() => {
                    EditorGUI.BeginChangeCheck();
                    var activeTargetBitmask = EditorGUILayout.MaskField(graphData.activeTargetBitmask, targetNameList.ToArray(), GUILayout.Width(100f));
                    if (EditorGUI.EndChangeCheck())
                    {
                        RegisterActionToUndo("Change active Targets");
                        graphData.activeTargetBitmask = activeTargetBitmask;
                        graphData.UpdateActiveTargets();
                        m_postChangeTargetSettingsCallback();
                    }
                }));
            });


            // Initialize from the active targets whenever user changes them
            // Is there a way to retain order even with that?
            if (userOrderedTargetNameList.Count != graphData.activeTargets.Count())
            {
                var activeTargetNames = graphData.activeTargets.Select(x => x.displayName);
                userOrderedTargetNameList = activeTargetNames.ToList();
            }

            var reorderableTextListView = new ReorderableListView <string>(userOrderedTargetNameList);

            reorderableTextListView.OnListReorderedCallback += list =>
            {
                userOrderedTargetNameList = (List <string>)list;
                onChange();
            };
            element.Add(reorderableTextListView);

            // Iterate active TargetImplementations
            foreach (var targetName in reorderableTextListView.TextList)
            {
                // Ensure enabled state is being tracked and get value
                bool foldoutActive = true;
                if (!m_TargetFoldouts.TryGetValue(targetName, out foldoutActive))
                {
                    m_TargetFoldouts.Add(targetName, foldoutActive);
                }

                // Create foldout
                var foldout = new Foldout()
                {
                    text = targetName, value = foldoutActive, name = "foldout"
                };
                element.Add(foldout);
                foldout.AddToClassList("MainFoldout");
                foldout.RegisterValueChangedCallback(evt =>
                {
                    // Update foldout value and rebuild
                    m_TargetFoldouts[targetName] = evt.newValue;
                    foldout.value = evt.newValue;
                    onChange();
                });

                if (foldout.value)
                {
                    var target = graphData.validTargets.Find(x => x.displayName == targetName);
                    // Get settings for Target
                    var context = new TargetPropertyGUIContext();
                    target.GetPropertiesGUI(ref context, onChange, RegisterActionToUndo);
                    element.Add(context);
                }
            }

            return(element);
        }
Beispiel #6
0
 public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo)
 {
 }
Beispiel #7
0
        public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo)
        {
            context.AddProperty("Surface", new EnumField(SurfaceType.Opaque)
            {
                value = target.surfaceType
            }, (evt) =>
            {
                if (Equals(target.surfaceType, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Surface");
                target.surfaceType = (SurfaceType)evt.newValue;
                onChange();
            });

            context.AddProperty("Blend", new EnumField(AlphaMode.Alpha)
            {
                value = target.alphaMode
            }, target.surfaceType == SurfaceType.Transparent, (evt) =>
            {
                if (Equals(target.alphaMode, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Blend");
                target.alphaMode = (AlphaMode)evt.newValue;
                onChange();
            });

            context.AddProperty("Alpha Clip", new Toggle()
            {
                value = target.alphaClip
            }, (evt) =>
            {
                if (Equals(target.alphaClip, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Alpha Clip");
                target.alphaClip = evt.newValue;
                onChange();
            });

            context.AddProperty("Two Sided", new Toggle()
            {
                value = target.twoSided
            }, (evt) =>
            {
                if (Equals(target.twoSided, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Two Sided");
                target.twoSided = evt.newValue;
                onChange();
            });
        }
        public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <String> registerUndo)
        {
            context.AddProperty("Affect BaseColor", new Toggle()
            {
                value = decalData.affectsAlbedo
            }, (evt) =>
            {
                if (Equals(decalData.affectsAlbedo, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Affect BaseColor");
                decalData.affectsAlbedo = (bool)evt.newValue;
                onChange();
            });

            context.AddProperty("Affect Normal", new Toggle()
            {
                value = decalData.affectsNormal
            }, (evt) =>
            {
                if (Equals(decalData.affectsNormal, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Affects Normal");
                decalData.affectsNormal = (bool)evt.newValue;
                onChange();
            });

            context.globalIndentLevel++;
            context.AddProperty("Blend", new Toggle()
            {
                value = decalData.affectsNormalBlend
            }, (evt) =>
            {
                if (Equals(decalData.affectsNormalBlend, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Affects Normal Blend");
                decalData.affectsNormalBlend = (bool)evt.newValue;
                onChange();
            });
            context.globalIndentLevel--;

            context.AddProperty("Affect MAOS", new Toggle()
            {
                value = decalData.affectsMAOS
            }, (evt) =>
            {
                if (Equals(decalData.affectsMAOS, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Affect MAOS");
                decalData.affectsMAOS = (bool)evt.newValue;
                onChange();
            });

            context.AddProperty("Affect Emission", new Toggle()
            {
                value = decalData.affectsEmission
            }, (evt) =>
            {
                if (Equals(decalData.affectsEmission, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Affect Emission");
                decalData.affectsEmission = (bool)evt.newValue;
                onChange();
            });

            context.AddProperty("Supports LOD Cross Fade", new Toggle()
            {
                value = decalData.supportLodCrossFade
            }, (evt) =>
            {
                if (Equals(decalData.supportLodCrossFade, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Supports LOD Cross Fade");
                decalData.supportLodCrossFade = (bool)evt.newValue;
                onChange();
            });

            context.AddProperty("Angle Fade", new Toggle()
            {
                value = decalData.angleFade
            }, (evt) =>
            {
                if (Equals(decalData.angleFade, evt.newValue))
                {
                    return;
                }

                registerUndo("Change Angle Fade");
                decalData.angleFade = (bool)evt.newValue;
                onChange();
            });
        }
Beispiel #9
0
        VisualElement GetSettings(GraphData graphData, Action onChange)
        {
            var element = new VisualElement()
            {
                name = "graphSettings"
            };

            if (graphData.isSubGraph)
            {
                return(element);
            }

            void RegisterActionToUndo(string actionName)
            {
                graphData.owner.RegisterCompleteObjectUndo(actionName);
            }

            // Add Label
            var targetSettingsLabel = new Label("Target Settings");

            targetSettingsLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
            element.Add(new PropertyRow(targetSettingsLabel));

            var targetList = new ReorderableListView <JsonData <Target> >(
                graphData.m_ActiveTargets,
                "Active Targets",
                false,      // disallow reordering (active list is sorted)
                target => target.value.displayName);

            targetList.GetAddMenuOptions = () => graphData.GetPotentialTargetDisplayNames();

            targetList.OnAddMenuItemCallback +=
                (list, addMenuOptionIndex, addMenuOption) =>
            {
                RegisterActionToUndo("Add Target");
                graphData.SetTargetActive(addMenuOptionIndex);
                m_postChangeTargetSettingsCallback();
            };

            targetList.RemoveItemCallback +=
                (list, itemIndex) =>
            {
                RegisterActionToUndo("Remove Target");
                graphData.SetTargetInactive(list[itemIndex].value);
                m_postChangeTargetSettingsCallback();
            };

            element.Add(targetList);

            // Iterate active TargetImplementations
            foreach (var target in graphData.activeTargets)
            {
                // Ensure enabled state is being tracked and get value
                bool foldoutActive;
                if (!m_TargetFoldouts.TryGetValue(target, out foldoutActive))
                {
                    foldoutActive = true;
                    m_TargetFoldouts.Add(target, foldoutActive);
                }

                // Create foldout
                var foldout = new Foldout()
                {
                    text = target.displayName, value = foldoutActive, name = "foldout"
                };
                element.Add(foldout);
                foldout.AddToClassList("MainFoldout");
                foldout.RegisterValueChangedCallback(evt =>
                {
                    // Update foldout value and rebuild
                    m_TargetFoldouts[target] = evt.newValue;
                    foldout.value            = evt.newValue;
                    onChange();
                });

                if (foldout.value)
                {
                    // Get settings for Target
                    var context = new TargetPropertyGUIContext();
                    target.GetPropertiesGUI(ref context, onChange, RegisterActionToUndo);
                    element.Add(context);
                }
            }

            return(element);
        }
 public override void GetPropertiesGUI(ref TargetPropertyGUIContext context, Action onChange, Action <string> registerUndo)
 {
     context.AddHelpBox(MessageType.Warning, "Cannot find the code for this SubTarget, a package may be missing.");
 }
        VisualElement GetSettings(GraphData graphData, Action onChange)
        {
            var element = new VisualElement()
            {
                name = "graphSettings"
            };

            if (graphData.isSubGraph)
            {
                return(element);
            }

            void RegisterActionToUndo(string actionName)
            {
                graphData.owner.RegisterCompleteObjectUndo(actionName);
            }

            // Add Label
            var targetSettingsLabel = new Label("Target Settings");

            targetSettingsLabel.style.unityFontStyleAndWeight = FontStyle.Bold;
            element.Add(new PropertyRow(targetSettingsLabel));

            var targetList = new ReorderableListView <JsonData <Target> >(
                graphData.m_ActiveTargets,
                "Active Targets",
                false,      // disallow reordering (active list is sorted)
                target => target.value.displayName);

            targetList.GetAddMenuOptions = () => graphData.GetPotentialTargetDisplayNames();

            targetList.OnAddMenuItemCallback +=
                (list, addMenuOptionIndex, addMenuOption) =>
            {
                RegisterActionToUndo("Add Target");
                graphData.SetTargetActive(addMenuOptionIndex);
                m_postChangeTargetSettingsCallback();
            };

            targetList.RemoveItemCallback +=
                (list, itemIndex) =>
            {
                RegisterActionToUndo("Remove Target");
                graphData.SetTargetInactive(list[itemIndex].value);
                m_postChangeTargetSettingsCallback();
            };

            element.Add(targetList);

            // Iterate active TargetImplementations
            foreach (var target in graphData.activeTargets)
            {
                // Ensure enabled state is being tracked and get value
                bool foldoutActive;
                if (!m_TargetFoldouts.TryGetValue(target, out foldoutActive))
                {
                    foldoutActive = true;
                    m_TargetFoldouts.Add(target, foldoutActive);
                }

                // Create foldout
                var foldout = new Foldout()
                {
                    text = target.displayName, value = foldoutActive, name = "foldout"
                };
                element.Add(foldout);
                foldout.AddToClassList("MainFoldout");
                foldout.RegisterValueChangedCallback(evt =>
                {
                    // Update foldout value and rebuild
                    m_TargetFoldouts[target] = evt.newValue;
                    foldout.value            = evt.newValue;
                    onChange();
                });

                if (foldout.value)
                {
                    // Get settings for Target
                    var context = new TargetPropertyGUIContext();
                    // Indent the content of the foldout
                    context.globalIndentLevel++;
                    target.GetPropertiesGUI(ref context, onChange, RegisterActionToUndo);
                    context.globalIndentLevel--;
                    element.Add(context);
                }
            }

#if VFX_GRAPH_10_0_0_OR_NEWER
            // Inform the user that VFXTarget is deprecated, if they are using one.
            var activeTargetSRP = graphData.m_ActiveTargets.Where(t => !(t.value is VFXTarget));
            if (graphData.m_ActiveTargets.Any(t => t.value is VFXTarget) && //Use Old VFXTarget
                activeTargetSRP.Any() &&
                activeTargetSRP.All(o => o.value.CanSupportVFX()))
            {
                var vfxWarning = new HelpBoxRow(MessageType.Info);

                var vfxWarningLabel = new Label("The Visual Effect target is deprecated.\n" +
                                                "Use the SRP target(s) instead, and enable 'Support VFX Graph' in the Graph Inspector.\n" +
                                                "Then, you can remove the Visual Effect Target.");

                vfxWarningLabel.style.color      = new StyleColor(Color.white);
                vfxWarningLabel.style.whiteSpace = WhiteSpace.Normal;

                vfxWarning.Add(vfxWarningLabel);
                element.Add(vfxWarning);
            }
#endif

            return(element);
        }