public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUIUtility.LookLikeControls();
        // EditorGUI.BeginProperty(position, label, property);
        // position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        var indent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        Rect SelectionSize = new Rect(position.x, position.y, 70, position.height);
        Rect componentSize = new Rect(position.x + SelectionSize.width, position.y, position.width - SelectionSize.width, position.height);

        selectedType = property.FindPropertyRelative("destination");
        selected     = (AddComponetTo)selectedType.enumValueIndex;
        selected     = (AddComponetTo)EditorGUI.EnumPopup(SelectionSize, selected);
        selectedType.enumValueIndex = (int)selected;

        EditorGUIUtility.LookLikeInspector();
        componentToAdd = property.FindPropertyRelative("component");
        componentToAdd.objectReferenceValue = EditorGUI.ObjectField(componentSize, componentToAdd.objectReferenceValue, typeof(MonoBehaviour), true);

        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        //EditorGUI.EndProperty();
    }
 public static void InitializeItemWithComponents(List <ItemData> items, AddComponetTo sourceToAddTo)
 {
     if (ItemComponentInitalizer.intilizer != null)
     {
         ItemComponentInitalizer.intilizer.AddComponentToItems(items, sourceToAddTo);
     }
 }
    private void AddComponentToItems(List <ItemData> items, AddComponetTo sourceToAddTo)
    {
        //todo only one for each or 2-3 nests max per function
        foreach (ItemData item in items)
        {
            foreach (ItemComponentSetup itemSetup in itemSetupList)
            {
                if (itemSetup == null)
                {
                    continue;
                }

                if (itemSetup.filter.IsSelected(item))
                {
                    foreach (ItemComponentSetup.ComponentPair pair in itemSetup.itemComponents)
                    {
                        if (pair.destination == sourceToAddTo || pair.destination == AddComponetTo.both)
                        {
                            Type type = pair.component.GetType();
                            item.gameObject.AddComponent(type.ToString());
                        }
                        else
                        {
                            Debug.Log("skipping adding " + pair.destination + " because the source was " + sourceToAddTo);
                            continue;
                        }
                    }
                }
            }
        }
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUIUtility.LookLikeControls();
        // EditorGUI.BeginProperty(position, label, property);
        // position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        var indent = EditorGUI.indentLevel;
        EditorGUI.indentLevel = 0;

        Rect SelectionSize = new Rect(position.x, position.y, 70, position.height);
        Rect componentSize = new Rect(position.x + SelectionSize.width, position.y, position.width - SelectionSize.width, position.height);

        selectedType = property.FindPropertyRelative("destination");
        selected = (AddComponetTo)selectedType.enumValueIndex;
        selected = (AddComponetTo)EditorGUI.EnumPopup(SelectionSize, selected);
        selectedType.enumValueIndex = (int)selected;

        EditorGUIUtility.LookLikeInspector();
        componentToAdd = property.FindPropertyRelative("component");
        componentToAdd.objectReferenceValue = EditorGUI.ObjectField(componentSize, componentToAdd.objectReferenceValue, typeof(MonoBehaviour), true);

        // Set indent back to what it was
        EditorGUI.indentLevel = indent;

        //EditorGUI.EndProperty();
    }
    private void AddComponentToItems(List<ItemData> items, AddComponetTo sourceToAddTo)
    {
        //todo only one for each or 2-3 nests max per function
        foreach (ItemData item in items)
        {
            foreach (ItemComponentSetup itemSetup in itemSetupList)
            {
                if (itemSetup == null) continue;

                if (itemSetup.filter.IsSelected(item))
                {
                    foreach (ItemComponentSetup.ComponentPair pair in itemSetup.itemComponents)
                    {
                        if (pair.destination == sourceToAddTo || pair.destination == AddComponetTo.both)
                        {
                            Type type = pair.component.GetType();
                            item.gameObject.AddComponent(type.ToString());
                        }
                        else
                        {
                            Debug.Log("skipping adding " + pair.destination + " because the source was " + sourceToAddTo);
                            continue;
                        }
                    }
                }
            }
        }
    }
 public static void InitializeItemWithComponents(List<ItemData> items, AddComponetTo sourceToAddTo)
 {
     if (ItemComponentInitalizer.intilizer != null)
     {
         ItemComponentInitalizer.intilizer.AddComponentToItems(items, sourceToAddTo);
     }
 }
 public static void InitializeItemWithComponents(ItemData item, AddComponetTo sourceToAddTo)
 {
     if (ItemComponentInitalizer.intilizer != null)
     {
         List <ItemData> items = new List <ItemData>();
         items.Add(item);
         ItemComponentInitalizer.intilizer.AddComponentToItems(items, sourceToAddTo);
     }
 }
 public static void InitializeItemWithComponents(ItemData item, AddComponetTo sourceToAddTo)
 {
     if (ItemComponentInitalizer.intilizer != null)
     {
         List<ItemData> items = new List<ItemData>();
         items.Add(item);
         ItemComponentInitalizer.intilizer.AddComponentToItems(items, sourceToAddTo);
     }
 }