Example #1
0
        public void Initialize(TypeSelectionFilter enable, Action <Type> onSelect)
        {
            _category = enable.Category;
            _onSelect = onSelect;
            TypeSelectionHolder.CheckInitialize(_category);

            // Indentation hack for search window
            _indentationIcon = new Texture2D(1, 1);
            _indentationIcon.SetPixel(0, 0, new Color(0, 0, 0, 0));
            _indentationIcon.Apply();
        }
Example #2
0
        public static void Show(TypeSelectionFilter enable, Vector2 position, float width, Action <Type> onSelected)
        {
            var provider = CreateInstance <TypeSelectionSearchWindow>();

            provider.Initialize(enable, (selectedType) =>
            {
                onSelected?.Invoke(selectedType);
                DestroyImmediate(provider);
            });

            SearchWindow.Open(
                new SearchWindowContext(
                    position,
                    width
                    ),
                provider
                );
        }
Example #3
0
 private void OnClick(
     TypeSelectionFilter attr,
     SerializedProperty property,
     Vector2 position,
     float width,
     Action <string> invoke
     )
 {
     TypeSelectionSearchWindow.Show(
         attr,
         position,
         width,
         type =>
     {
         Undo.RecordObject(property.serializedObject.targetObject, "update TypeSelection");
         var value = JsonUtility.FromJson("{}", type);
         property.SetValue(value);
         property.serializedObject.ApplyModifiedProperties();
         property.serializedObject.Update();
         invoke(value?.GetType()?.Name ?? "None");
     });
 }