Example #1
0
        protected override void OnBound(ExposedField property, IExposedToLevelEditor exposed)
        {
            if (property.Type == typeof(Vector2))
            {
                type = VectorTypes.Vector2;
            }
            else if (property.Type == typeof(Vector2Int))
            {
                type = VectorTypes.Vector2Int;
            }
            else if (property.Type == typeof(Vector3))
            {
                type = VectorTypes.Vector3;
            }
            else if (property.Type == typeof(Vector3Int))
            {
                type = VectorTypes.Vector3Int;
            }
            else if (property.Type == typeof(Vector4))
            {
                type = VectorTypes.Vector4;
            }
            else
            {
                type = VectorTypes.Invalid;
            }

            xField.contentType = IsInt ? TMP_InputField.ContentType.IntegerNumber : TMP_InputField.ContentType.DecimalNumber;
            yField.contentType = IsInt ? TMP_InputField.ContentType.IntegerNumber : TMP_InputField.ContentType.DecimalNumber;
        }
        public void Bind(ExposedField property, IExposedToLevelEditor exposed)
        {
            exposed.OnValueChanged += OnExposedValueChanged;

            boundProperty  = property;
            boundComponent = exposed;

#if ALE_LOCALIZATION
            if (!string.IsNullOrWhiteSpace(property.CustomName) && localStringComp != null)
            {
                Label = TextUtility.FormatVariableLabel(property.Name);
                LocalizedString result = UI.InspectorPanel.GetLocalizedInspectorField(property.CustomName);
                if (result != null)
                {
                    localStringComp.StringReference = result;
                }
            }
            else
#endif
            {
                Label = string.IsNullOrEmpty(property.CustomName) ? TextUtility.FormatVariableLabel(property.Name) : property.CustomName;
            }

            OnBound(property, exposed);
            SetFieldValue(exposed.GetValue(property.ID));
        }
Example #3
0
        protected override void OnBound(ExposedField property, IExposedToLevelEditor exposed)
        {
            isChar = property.Type == typeof(char);

            textField.characterLimit = isChar ? 1 : 0;

            if (placeholderAsName && textField.placeholder is TextMeshProUGUI placeholder)
            {
                placeholder.text = property.Name;
            }
        }
Example #4
0
 protected bool TryGetField <T>(ExposedField property, out LevelEditorInspectorField field)
 {
     if (Inspector.HasField(typeof(T)))
     {
         field = Inspector.GetField(typeof(T), content);
         field.Bind(property, Exposed);
         return(true);
     }
     else
     {
         field = null;
         return(false);
     }
 }
Example #5
0
        protected override void OnBound(ExposedField property, IExposedToLevelEditor exposed)
        {
            enumNames.Clear();
            enumValues.Clear();

            string[] names = Enum.GetNames(property.Type);
            enumNames.AddRange(names);

            Array values = Enum.GetValues(property.Type);

            for (int i = 0; i < values.Length; i++)
            {
                enumValues.Add(values.GetValue(i));
            }

            dropdown.ClearOptions();

            for (int i = 0; i < enumNames.Count; i++)
            {
                dropdown.options.Add(new TMP_Dropdown.OptionData(enumNames[i]));
            }

            dropdown.RefreshShownValue();
        }
 protected virtual void OnBound(ExposedField property, IExposedToLevelEditor exposed)
 {
 }
Example #7
0
        protected override void OnBound(ExposedField property, IExposedToLevelEditor exposed)
        {
            editing = false;

            if (property.Type == typeof(sbyte))
            {
                currentType = NumberType.Sbyte;
            }
            else if (property.Type == typeof(byte))
            {
                currentType = NumberType.Byte;
            }
            else if (property.Type == typeof(short))
            {
                currentType = NumberType.Short;
            }
            else if (property.Type == typeof(ushort))
            {
                currentType = NumberType.UShort;
            }
            else if (property.Type == typeof(int))
            {
                currentType = NumberType.Int;
            }
            else if (property.Type == typeof(uint))
            {
                currentType = NumberType.UInt;
            }
            else if (property.Type == typeof(long))
            {
                currentType = NumberType.Long;
            }
            else if (property.Type == typeof(ulong))
            {
                currentType = NumberType.ULong;
            }
            else if (property.Type == typeof(float))
            {
                currentType = NumberType.Float;
            }
            else if (property.Type == typeof(double))
            {
                currentType = NumberType.Double;
            }
            else
            {
                currentType = NumberType.Decimal;
            }

            switch (currentType)
            {
            case NumberType.Sbyte:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.Byte:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.Short:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.UShort:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.Int:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.UInt:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.Long:
            case NumberType.ULong:
                textField.contentType = TMP_InputField.ContentType.IntegerNumber;
                break;

            case NumberType.Float:
                textField.contentType = TMP_InputField.ContentType.DecimalNumber;
                break;

            case NumberType.Double:
                textField.contentType = TMP_InputField.ContentType.DecimalNumber;
                break;

            case NumberType.Decimal:
                textField.contentType = TMP_InputField.ContentType.DecimalNumber;
                break;
            }

            if (placeholderAsName && textField.placeholder is TextMeshProUGUI placeholder)
            {
                placeholder.text = property.Name;
            }
        }