public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(bool_fieldKey, out _bool_field);
                dict.TryGetInt(int_fieldKey, out _int_field);
                dict.TryGetFloat(float_fieldKey, out _float_field);
                dict.TryGetString(string_fieldKey, out _string_field);
                dict.TryGetVector2(vector2_fieldKey, out _vector2_field);
                dict.TryGetVector3(vector3_fieldKey, out _vector3_field);
                dict.TryGetVector4(vector4_fieldKey, out _vector4_field);
                dict.TryGetColor(color_fieldKey, out _color_field);

                string customDataKey;
                dict.TryGetString(custom_fieldKey, out customDataKey);
                GDEDataManager.DataDictionary.TryGetCustom(customDataKey, out _custom_field);
                LoadFromSavedData(dataKey);
            }
        }
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(bool_fieldKey, out _bool_field);
                dict.TryGetInt(int_fieldKey, out _int_field);
                dict.TryGetFloat(float_fieldKey, out _float_field);
                dict.TryGetString(descriptionKey, out _description);
                dict.TryGetString(string_fieldKey, out _string_field);
                dict.TryGetVector2(vector2_fieldKey, out _vector2_field);
                dict.TryGetVector3(vector3_fieldKey, out _vector3_field);
                dict.TryGetColor(color_fieldKey, out _color_field);
                LoadFromSavedData(dataKey);
            }
        }
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetInt(projectileRangeKey, out _projectileRange);
                dict.TryGetInt(numberOfUsesKey, out _numberOfUses);
                dict.TryGetInt(CostOfUseKey, out _CostOfUse);
                dict.TryGetFloat(itemDurationKey, out _itemDuration);
                dict.TryGetString(itemTypeKey, out _itemType);
                dict.TryGetGameObject(ItemModelKey, out _ItemModel);
                LoadFromSavedData(dataKey);
            }
        }
    protected virtual void DrawListColor(int index, Dictionary<string, object> value, List<object> colorList)
    {
        try
        {
            Color newValue;
            Color currentValue = Color.white;

            value.TryGetFloat("r", out currentValue.r);
            value.TryGetFloat("g", out currentValue.g);
            value.TryGetFloat("b", out currentValue.b);
            value.TryGetFloat("a", out currentValue.a);

            GUIContent content = new GUIContent(string.Format("{0}:", index));
            Vector2 size = labelStyle.CalcSize(content);
            EditorGUI.LabelField(new Rect(currentLinePosition, TopOfLine(), size.x, StandardHeight()), content);
            currentLinePosition += (size.x + 2);

            float width = 230 - size.x;
            newValue = EditorGUI.ColorField(new Rect(currentLinePosition, TopOfLine(), width, StandardHeight()), currentValue);
            currentLinePosition += (width + 2);

            if (newValue != currentValue)
            {
                value.TryAddOrUpdateValue("r", newValue.r);
                value.TryAddOrUpdateValue("g", newValue.g);
                value.TryAddOrUpdateValue("b", newValue.b);
                value.TryAddOrUpdateValue("a", newValue.a);

                colorList[index] = value;
                SetNeedToSave(true);
            }
        }
        catch (Exception ex)
        {
            // Don't log ExitGUIException here. This is a unity bug with ObjectField and ColorField.
            if (!(ex is ExitGUIException))
                Debug.LogException(ex);
        }
    }
Example #5
0
        public override void LoadFromDict(string dataKey, Dictionary<string, object> dict)
        {
            _key = dataKey;

            if (dict == null)
                LoadFromSavedData(dataKey);
            else
            {
                dict.TryGetBool(stage_lockKey, out _stage_lock);
                dict.TryGetInt(base_scoreKey, out _base_score);
                dict.TryGetInt(high_scoreKey, out _high_score);
                dict.TryGetFloat(remain_fuelKey, out _remain_fuel);
                dict.TryGetFloat(base_fuelKey, out _base_fuel);
                dict.TryGetGameObject(game_objectKey, out _game_object);
                LoadFromSavedData(dataKey);
            }
        }