예제 #1
0
        public void AddProperty(string key, CollectionModel.JsonSchemaProperty jsonSchemaProperty)
        {
            GameObject gameObject = Instantiate(
                collectionPropertyItemController.gameObject,
                collectionPropertyItemController.transform.parent
                );

            gameObject.SetActive(true);

            CollectionPropertyItemController cpItemController = gameObject.GetComponent <CollectionPropertyItemController>();

            cpItemController.SetJsonSchemaProperty(key, jsonSchemaProperty);
        }
예제 #2
0
        public void SetJsonSchemaProperty(string key, CollectionModel.JsonSchemaProperty jsonSchemaProperty)
        {
            keyInput.text = key;

            string type = jsonSchemaProperty.type;

            if (type == "string" && jsonSchemaProperty.format == "date-time")
            {
                typeDropdown.value = typeDropdown.options.FindIndex(o => o.text.ToLower() == "timestamp");
            }
            else
            {
                typeDropdown.value = typeDropdown.options.FindIndex(o => o.text.ToLower() == type);
            }

            dynamic defaultValue = jsonSchemaProperty.@default;

            if (defaultValue != null)
            {
                switch (type)
                {
                case "boolean":
                    defaultBooleanDropdown.value = defaultBooleanDropdown.options.FindIndex(o => o.text.ToLower() == defaultValue.ToString());
                    break;

                case "number":
                    defaultNumberDropdown.text = defaultValue.ToString();
                    break;

                case "string":
                    defaultStringDropdown.text = defaultValue;
                    break;
                }
            }

            SetDefault();
        }