Пример #1
0
        public void CheckTypeMenu(SerializedProperty property, VFXPropertyBindingAttribute attribute, VisualEffectAsset asset)
        {
            GenericMenu menu       = new GenericMenu();
            var         parameters = (asset.GetResource().graph as UnityEditor.VFX.VFXGraph).children.OfType <UnityEditor.VFX.VFXParameter>();

            foreach (var param in parameters)
            {
                string typeName = param.type.ToString();
                if (attribute.EditorTypes.Contains(typeName))
                {
                    MenuPropertySetName set = new MenuPropertySetName
                    {
                        property = property,
                        value    = param.exposedName
                    };
                    menu.AddItem(new GUIContent(param.exposedName), false, SetFieldName, set);
                }
            }

            menu.ShowAsContext();
        }
        public void CheckTypeMenu(SerializedProperty property, VFXPropertyBindingAttribute attribute, VisualEffectAsset asset)
        {
            VFXGraph graph = null;

            if (asset != null)
            {
                var resource = asset.GetResource();
                if (resource != null) //If VisualEffectGraph is store in asset bundle, we can't use this following code
                {
                    graph = resource.graph as VFXGraph;
                }
            }

            if (graph == null)
            {
                return;
            }

            var menu       = new GenericMenu();
            var parameters = graph.children.OfType <UnityEditor.VFX.VFXParameter>();

            foreach (var param in parameters)
            {
                string typeName = param.type.ToString();
                if (attribute.EditorTypes.Contains(typeName))
                {
                    MenuPropertySetName set = new MenuPropertySetName
                    {
                        property = property,
                        value    = param.exposedName
                    };
                    menu.AddItem(new GUIContent(param.exposedName), false, SetFieldName, set);
                }
            }

            menu.ShowAsContext();
        }