private void CreateFieldFor(IGenericInspectorField field)
        {
            IInspectorFieldView fieldView = null;

            if (kInputFieldInspectorIndustry.ContainsKey(field.Type))
            {
                GameObject inputFieldObject = GameObject.Instantiate(inputFieldInspectorPrefab_, parent: container_.transform);
                fieldView = inputFieldObject.GetComponent <IInspectorFieldView>();
                var inputFieldInspector = inputFieldObject.GetComponent <InputFieldInspector>();
                inputFieldInspector.Init(kInputFieldInspectorIndustry[field.Type].Invoke(field));
            }
            else if (field.Type == typeof(bool))
            {
                fieldView = GameObject.Instantiate(toggleInspectorPrefab_, parent: container_.transform).GetComponent <IInspectorFieldView>();
            }
            else if (field.Type == typeof(ToggleButtonInspectorField))
            {
                fieldView = GameObject.Instantiate(toggleButtonInspectorPrefab_, parent: container_.transform).GetComponent <IInspectorFieldView>();
            }
            else if (field.Type == typeof(ButtonInspectorField))
            {
                fieldView = GameObject.Instantiate(buttonInspectorPrefab_, parent: container_.transform).GetComponent <IInspectorFieldView>();
            }
            else if (field.Type == typeof(PopupInspectorField))
            {
                fieldView = GameObject.Instantiate(popupInspectorPrefab_, parent: container_.transform).GetComponent <IInspectorFieldView>();
            }
            else if (field.Type == typeof(HeaderInspectorField))
            {
                fieldView = GameObject.Instantiate(headerInspectorPrefab_, parent: container_.transform).GetComponent <IInspectorFieldView>();
            }
            else if (field.Type == typeof(LabelInspectorField))
            {
                fieldView = GameObject.Instantiate(labelInspectorPrefab_, parent: container_.transform).GetComponent <IInspectorFieldView>();
            }
            else if (field.Type == typeof(DynamicGroupInspectorField))
            {
                var dynamicGroup = field as DynamicGroupInspectorField;
                if (!dynamicGroup.Enabled)
                {
                    return;
                }

                foreach (var nestedField in dynamicGroup.Fields)
                {
                    CreateFieldFor(nestedField);
                }
                return;
            }

            if (fieldView == null)
            {
                Debug.LogWarning("Failed to find prefab for IGenericInspectorField with type: " + field.Type);
                return;
            }
            fieldView.Init(field);
        }
Пример #2
0
        // PRAGMA MARK - IInspectorFieldView Implementation
        void IInspectorFieldView.Init(IGenericInspectorField field)
        {
            Field_ = field;

            if (displayNameText_ != null)
            {
                displayNameText_.text = Field_.DisplayName;
            }

            InternalInit();
        }
Пример #3
0
 private void RegisterField(IGenericInspectorField field)
 {
     if (dynamicGroup_ != null)
     {
         dynamicGroup_.Add(field);
     }
     else
     {
         fields_.Add(field);
     }
     DirtySelf();
 }
        protected override void InternalInit()
        {
            boolField_ = Field_ as IGenericInspectorField <bool>;
            if (boolField_ == null)
            {
                Debug.LogWarning("ToggleFieldInspector - failed to cast to IGenericInspectorField<bool>! Field_: " + Field_);
                return;
            }

            toggle_.onValueChanged.AddListener(HandleValueChanged);
            toggle_.isOn = boolField_.Getter.Invoke();
        }
 public void Add(IGenericInspectorField field)
 {
     fields_.Add(field);
 }
Пример #6
0
 // PRAGMA MARK - Public Interface
 public StringInputFieldInspectorController(IGenericInspectorField field)
 {
     field_ = field as IGenericInspectorField <string>;
 }
 // PRAGMA MARK - Public Interface
 public IntInputFieldInspectorController(IGenericInspectorField field)
 {
     field_ = field as IGenericInspectorField <int>;
 }
 // PRAGMA MARK - Public Interface
 public ColorInputFieldInspectorController(IGenericInspectorField field)
 {
     field_ = field as IGenericInspectorField <Color>;
 }