void RenderModelOptions() { GUILayout.Space(10); GUILayout.Label("SETUP OPTIONS", sectionTitleStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); GUILayout.BeginVertical(); Field[] options = getSelectedModel().options == null ? new Field[0] : getSelectedModel().options; for (var i = 0; i < options.Length; i++) { GUILayout.Space(5); Field option = options[i]; if (option.type == "category" || option.type == "file") { GUILayout.BeginHorizontal(horizontalStyle); GUILayout.Label(RunwayUtils.FormatFieldName(option.name)); GUILayout.FlexibleSpace(); optionSelectionIndices[i] = EditorGUILayout.Popup(optionSelectionIndices[i], option.oneOf); GUILayout.EndHorizontal(); } } GUILayout.Space(5); GUILayout.EndVertical(); GUILayout.EndHorizontal(); }
void RenderInputsAndOutputs() { Field[] inputs = getFilteredModels()[selectedModelIndex].commands[0].inputs; Field[] outputs = getFilteredModels()[selectedModelIndex].commands[0].outputs; GUILayout.Space(10); GUILayout.Label("INPUT", sectionTitleStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); GUILayout.BeginVertical(); for (int i = 0; i < inputs.Length; i++) { GUILayout.Space(5); Field input = inputs[i]; GUILayout.BeginVertical(); if (input.type.Equals("image") || input.type.Equals("segmentation")) { GUILayout.BeginHorizontal(horizontalStyle); GUILayout.FlexibleSpace(); GUILayout.Label(RunwayUtils.FormatFieldName(input.name), boldTextStyle); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(5); } if (input.type.Equals("image")) { RenderImageInput(input, i); } else if (input.type.Equals("segmentation")) { RenderSegmentationInput(input, i); } else if (input.type.Equals("text")) { GUILayout.BeginHorizontal(horizontalStyle); GUILayout.Label(System.String.Format("{0}:", RunwayUtils.FormatFieldName(input.name))); GUILayout.FlexibleSpace(); inputData[input.name] = EditorGUILayout.TextField(inputData[input.name] as string, GUILayout.MaxWidth(250)); GUILayout.EndHorizontal(); } else if (input.type.Equals("category")) { GUILayout.BeginHorizontal(horizontalStyle); GUILayout.Label(System.String.Format("{0}:", RunwayUtils.FormatFieldName(input.name))); GUILayout.FlexibleSpace(); inputData[input.name] = RunwayUtils.Dropdown(inputData[input.name] as string, input.oneOf); GUILayout.EndHorizontal(); } else if (input.type.Equals("number")) { GUILayout.BeginHorizontal(horizontalStyle); GUILayout.Label(System.String.Format("{0}:", RunwayUtils.FormatFieldName(input.name))); GUILayout.FlexibleSpace(); if (RunwayUtils.IsAnInteger(input.step)) { if (input.hasMin && input.hasMax && input.hasStep) { int value = inputData[input.name] is int?(int)inputData[input.name] : (int)Convert.ToSingle(input.defaultValue); inputData[input.name] = EditorGUILayout.IntSlider(value, (int)input.min, (int)input.max); } else { int value = inputData[input.name] is int?(int)inputData[input.name] : (int)Convert.ToSingle(input.defaultValue); inputData[input.name] = EditorGUILayout.IntField(value); } } else { if (input.hasMin && input.hasMax && input.hasStep) { float value = inputData[input.name] is float?(float)inputData[input.name] : (float)Convert.ToSingle(input.defaultValue); inputData[input.name] = EditorGUILayout.Slider(value, input.min, input.max); } else { float value = inputData[input.name] is float?(float)inputData[input.name] : Convert.ToSingle(input.defaultValue); inputData[input.name] = EditorGUILayout.FloatField(value); } } GUILayout.EndHorizontal(); } else if (input.type.Equals("boolean")) { GUILayout.BeginHorizontal(horizontalStyle); GUILayout.Label(System.String.Format("{0}:", RunwayUtils.FormatFieldName(input.name))); bool value = inputData[input.name] is bool?(bool)inputData[input.name] : false; GUILayout.FlexibleSpace(); inputData[input.name] = EditorGUILayout.Toggle(value, GUILayout.Width(20)); GUILayout.EndHorizontal(); } GUILayout.Space(5); GUILayout.EndVertical(); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label("OUTPUT", sectionTitleStyle); GUILayout.Space(5); GUILayout.BeginHorizontal("box"); GUILayout.BeginVertical(); GUILayout.Space(5); GUILayout.BeginHorizontal(horizontalStyle); GUILayout.FlexibleSpace(); if (this.lastOutput) { RenderTextureInfo(this.lastOutput); } else { RenderNotAvailable(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Preview")) { outputWindow = GetWindow <RunwayOutputWindow>(false, "Runway - Model Output", true); } GUILayout.Space(5); if (this.lastOutput && GUILayout.Button("Save")) { string path = EditorUtility.SaveFilePanel("Save as PNG", "", "ModelOutput.png", "png"); byte[] data = RunwayUtils.TextureToPNG(this.lastOutput); File.WriteAllBytes(path, data); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (lastOutput != null && outputWindow != null) { outputWindow.texture = lastOutput; outputWindow.Repaint(); } }