Ejemplo n.º 1
0
        private string GetJsonSchemaType(CollectionPropertyItemController controller)
        {
            int    typeIndex = controller.typeDropdown.value;
            string type      = controller.typeDropdown.options[typeIndex].text;

            return(type == "Timestamp" ? "string" : type.ToLower());
        }
Ejemplo n.º 2
0
        private dynamic GetJsonSchemaDefault(CollectionPropertyItemController controller)
        {
            int    typeIndex = controller.typeDropdown.value;
            string type      = controller.typeDropdown.options[typeIndex].text;

            switch (type)
            {
            case "Boolean":
                TMP_Dropdown dropdown      = controller.defaultBooleanDropdown;
                string       booleanString = dropdown.options[dropdown.value].text;
                return(booleanString == "True");

            case "Number":
                string numberString = controller.defaultNumberDropdown.text;
                return(string.IsNullOrEmpty(numberString) ?
                       0f :
                       float.Parse(numberString, System.Globalization.CultureInfo.InvariantCulture));

            case "String":
                return(string.IsNullOrEmpty(controller.defaultStringDropdown.text) ?
                       "" :
                       controller.defaultStringDropdown.text);
            }

            return(null);
        }
Ejemplo n.º 3
0
        private string GetJsonSchemaFormat(CollectionPropertyItemController controller)
        {
            int    typeIndex = controller.typeDropdown.value;
            string type      = controller.typeDropdown.options[typeIndex].text;

            return(type == "Timestamp" ? "date-time" : null);
        }
        private string GetFieldType(string field)
        {
            CollectionPropertyItemController[] controllers = propertiesContainer.GetComponentsInChildren <CollectionPropertyItemController>();
            CollectionPropertyItemController   controller  = controllers.First(c => field == c.keyInput.text);

            return(controller.typeDropdown.options[controller.typeDropdown.value].text);
        }
Ejemplo n.º 5
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);
        }