internal static void CreateAndShow(UnityEngine.Object[] targets)
        {
            PresetContextMenu presetContextMenu = ScriptableObject.CreateInstance <PresetContextMenu>();

            if (targets[0] is AssetImporter)
            {
                presetContextMenu.m_ImporterEditors = (from e in Resources.FindObjectsOfTypeAll <AssetImporterEditor>()
                                                       where e.targets == targets
                                                       select e).ToArray <AssetImporterEditor>();
                presetContextMenu.m_Targets = new UnityEngine.Object[]
                {
                    UnityEngine.Object.Instantiate(targets[0])
                };
                presetContextMenu.m_ImporterSerialized = new SerializedObject(targets);
                SerializedProperty iterator = presetContextMenu.m_ImporterEditors[0].m_SerializedObject.GetIterator();
                while (iterator.Next(true))
                {
                    presetContextMenu.m_ImporterSerialized.CopyFromSerializedProperty(iterator);
                }
            }
            else
            {
                presetContextMenu.m_Targets = targets;
                presetContextMenu.m_Presets = (from t in targets
                                               select new Preset(t)).ToArray <Preset>();
            }
            PresetSelector.ShowSelector(targets[0], null, true, presetContextMenu);
        }
示例#2
0
        public static bool DrawPresetButton(Rect rectangle, Object[] targets)
        {
            var target = targets[0];

            if (Preset.IsObjectExcludedFromPresets(target) ||
                (target.hideFlags & HideFlags.NotEditable) != 0)
            {
                return(false);
            }

            if (EditorGUI.DropdownButton(rectangle, Style.presetIcon, FocusType.Passive,
                                         EditorStyles.iconButton))
            {
                PresetContextMenu.CreateAndShow(targets);
            }
            return(true);
        }
示例#3
0
        public static bool DrawPresetButton(Rect rectangle, UnityEngine.Object[] targets)
        {
            UnityEngine.Object @object = targets[0];
            bool result;

            if (Preset.IsObjectExcludedFromPresets(@object) || (@object.hideFlags & HideFlags.NotEditable) != HideFlags.None)
            {
                result = false;
            }
            else
            {
                if (EditorGUI.DropdownButton(rectangle, PresetSelector.Style.presetIcon, FocusType.Passive, EditorStyles.iconButton))
                {
                    PresetContextMenu.CreateAndShow(targets);
                }
                result = true;
            }
            return(result);
        }