public static PropertyField ( UnityEditor.SerializedProperty property ) : bool | ||
property | UnityEditor.SerializedProperty | The SerializedProperty to make a field for. |
리턴 | bool |
void DrawActionButtonArrayElement(SP dialog, int elementIndex) { DrawArrayElement(dialog, elementIndex, "Consent dialog should have at least 1 button.", MinActionButtonsCount, () => SelectedButtonIndex, param => SelectedButtonIndex = param, obj => { var title = obj.FindPropertyRelative("title"); EditorGUI.indentLevel++; string key = obj.propertyPath; if (!privacyFoldoutStates.ContainsKey(key)) { privacyFoldoutStates.Add(key, false); } string titleValue = !string.IsNullOrEmpty(title.stringValue) ? title.stringValue : "[Untitled Button]"; privacyFoldoutStates[key] = EGL.Foldout(privacyFoldoutStates[key], titleValue, true); EditorGUI.indentLevel--; if (privacyFoldoutStates[key]) { EGL.PropertyField(obj.FindPropertyRelative("id")); EGL.PropertyField(title); EGL.PropertyField(obj.FindPropertyRelative("interactable")); EGL.PropertyField(obj.FindPropertyRelative("titleColor")); EGL.PropertyField(obj.FindPropertyRelative("backgroundColor")); EGL.PropertyField(obj.FindPropertyRelative("uninteractableTitleColor")); EGL.PropertyField(obj.FindPropertyRelative("uninteractableBackgroundColor")); } }); }
void drawArray(string arrayName) { SerializedObject so = new SerializedObject(this); SerializedProperty stringsProperty = so.FindProperty(arrayName); EGL.PropertyField(stringsProperty, true); so.ApplyModifiedProperties(); }
void DrawPrivacyConsentDialogSettingsGUI() { DrawUppercaseSection("CONSENT_DIALOG_COMPOSER_FOLDOUT_KEY", "DEFAULT CONSENT DIALOG COMPOSER", () => { // Dialog title. EGL.Space(); EGL.LabelField("Dialog Title", ES.boldLabel); EGL.PropertyField(PrivacyProperties.consentDialogTitle.property); // Draw the main content. EGL.Space(); EGL.LabelField("Main Content", ES.boldLabel); EGL.LabelField(ContentDescription, ES.helpBox); DrawConsentDialogContentEditor(); // Draw the toggles array. SP togglesArray = PrivacyProperties.consentDialogToggles.property; if (togglesArray.arraySize < MinTogglesCount) { togglesArray.arraySize += MinTogglesCount - togglesArray.arraySize; } EGL.Space(); EGL.LabelField("Toggle List", ES.boldLabel); EGL.LabelField(TogglesArrayDescription, ES.helpBox); togglesFoldout = DrawResizableArray(togglesArray, togglesFoldout, "Toggles", DrawToggleArrayElement, UpdateNewTogglePropertyInfo); // Draw the buttons array. SP buttonsArray = PrivacyProperties.consentDialogActionButtons.property; if (buttonsArray.arraySize < MinActionButtonsCount) { buttonsArray.arraySize += MinActionButtonsCount - buttonsArray.arraySize; } EGL.Space(); EGL.LabelField("Button List", ES.boldLabel); EGL.LabelField(ButtonsArrayDescription, ES.helpBox); buttonsFoldout = DrawResizableArray(buttonsArray, buttonsFoldout, "Buttons", DrawActionButtonArrayElement, UpdateNewButtonPropertyInfo); // Preview button. EGL.Space(); EGL.LabelField("Preview", ES.boldLabel); EGL.LabelField(PreviewSectionDescription, ES.helpBox); if (GUILayout.Button("Run Preview Scene") && !EditorApplication.isPlaying) { if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo()) { EditorSceneManager.OpenScene(EM_Constants.DemoPrivacyScenePath); EditorApplication.isPlaying = true; } } }); }
private void ShowGameObjectInformation() { field.useArrayOfAsteroids = EGL.Toggle("Use Array", field.useArrayOfAsteroids); if (field.useArrayOfAsteroids) { SerializedObject serialObject = new SerializedObject(target); SerializedProperty serialProperty = serialObject.FindProperty("asteroids"); EGL.PropertyField(serialProperty, new GUIContent("Asteroids"), true); serialObject.ApplyModifiedProperties(); } else { var newAsteroidGameObject = (GameObject)EGL.ObjectField(new GUIContent("Asteroid Game Object", "The game object that represents the spawned asteroids"), field.asteroid, typeof(GameObject), false); if (GUI.changed) { field.asteroid = newAsteroidGameObject; } } }
void DrawToggleArrayElement(SP dialog, int elementIndex) { DrawArrayElement(dialog, elementIndex, "", MinTogglesCount, () => SelectedToggleIndex, param => SelectedToggleIndex = param, obj => { var shouldToggleContent = new GUIContent("Toggle Description", "Change description when toggle is updated."); var shouldToggleOnDescriptionContent = new GUIContent("Toggle On Description", "This description will be displayed if the toggle value is true."); var shouldToggleOffDescriptionContent = new GUIContent("Description", "This description will be displayed regardless of the toggle value."); var offDescriptionContent = new GUIContent("Toggle Off Description", "This description will be displayed if the toggle value is false."); var title = obj.FindPropertyRelative("title"); string key = obj.propertyPath; if (!privacyFoldoutStates.ContainsKey(key)) { privacyFoldoutStates.Add(key, false); } EditorGUI.indentLevel++; string titleValue = !string.IsNullOrEmpty(title.stringValue) ? title.stringValue : "[Untitled Toggle]"; privacyFoldoutStates[key] = EGL.Foldout(privacyFoldoutStates[key], titleValue, true); EditorGUI.indentLevel--; if (privacyFoldoutStates[key]) { EGL.PropertyField(obj.FindPropertyRelative("id")); EGL.PropertyField(title); EGL.PropertyField(obj.FindPropertyRelative("isOn")); EGL.PropertyField(obj.FindPropertyRelative("interactable")); var shouldToggle = obj.FindPropertyRelative("shouldToggleDescription"); EGL.PropertyField(shouldToggle, shouldToggleContent); // On description. var onDescription = obj.FindPropertyRelative("onDescription"); onDescription.stringValue = EGL.TextField( shouldToggle.boolValue ? shouldToggleOnDescriptionContent : shouldToggleOffDescriptionContent, onDescription.stringValue, new GUIStyle(ES.textField) { wordWrap = true }, GUILayout.Height(EditorGUIUtility.singleLineHeight * 3)); if (shouldToggle.boolValue) { var offDescription = obj.FindPropertyRelative("offDescription"); offDescription.stringValue = EGL.TextField( offDescriptionContent, offDescription.stringValue, new GUIStyle(ES.textField) { wordWrap = true }, GUILayout.Height(EditorGUIUtility.singleLineHeight * 3)); } } }); }
public override void OnInspectorGUI() { EGL.LabelField("已有道具:"); items = ItemXmlManager.XmlReader.FindItems(); for (int i = 0; i < items.Count; i++) { EGL.BeginHorizontal(); EGL.LabelField(items[i]); if (!tryToAddNewItem && tryToModify == -1) { if (GUILayout.Button("修改")) { tryToModify = i; sm.LoadItemClassInfo(items[tryToModify]); so.Update(); } if (GUILayout.Button("删除")) { sm.DeleteItemClass(items[i]); so.Update(); } } EGL.EndHorizontal(); } if (tryToModify == -1 && tryToAddNewItem == false) { EGL.Separator(); EGL.Separator(); EGL.Separator(); EGL.Separator(); if (GUILayout.Button("添加一个新道具")) { tryToAddNewItem = true; sm.GetNewItemTemplate(); so.Update(); } } if (tryToModify != -1) { tryToAddNewItem = false; EGL.Separator(); EGL.Separator(); EGL.LabelField("类名: " + items[tryToModify]); EGL.PropertyField(newItemName, new GUIContent("道具名字")); EGL.PropertyField(resources, new GUIContent("道具预置体")); EGL.LabelField("该预置体必须处于\"Resource/ItemPrefabs\"文件夹下!"); EGL.BeginHorizontal(); EGL.PropertyField(parameterName, new GUIContent("参数名字"), true); EGL.PropertyField(parameterValue, new GUIContent("参数值"), true); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GUILayout.Button("应用")) { so.ApplyModifiedProperties(); sm.ModifyItem(items[tryToModify]); so.Update(); tryToModify = -1; } if (GUILayout.Button("取消")) { tryToModify = -1; } EGL.EndHorizontal(); } if (tryToAddNewItem) { EGL.Separator(); EGL.Separator(); EGL.PropertyField(newItemClassName, new GUIContent("类名")); EGL.PropertyField(newItemName, new GUIContent("道具名字")); EGL.PropertyField(resources, new GUIContent("道具预置体")); EGL.LabelField("该预置体必须处于\"Resource/ItemPrefabs\"文件夹下!"); EGL.BeginHorizontal(); EGL.PropertyField(parameterName, new GUIContent("参数名字"), true); EGL.PropertyField(parameterValue, new GUIContent("参数值"), true); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GUILayout.Button("应用")) { so.ApplyModifiedProperties(); if (sm.CreateNewItemClass()) { tryToAddNewItem = false; msg = ""; } else { msg = "请先删除重名类!或更改一个新类名"; } } if (GUILayout.Button("取消")) { tryToAddNewItem = false; msg = ""; } EGL.EndHorizontal(); } EGL.LabelField(msg); }
public override void OnInspectorGUI() { serializedObject.UpdateIfRequiredOrScript(); Label("General", EditorStyles.boldLabel); E.PropertyField(serializedObject.FindProperty(nameof(VT0Info.ThumbSize))); E.PropertyField(serializedObject.FindProperty(nameof(VT0Info.MemoryCompression))); var vramBytes = ((VT0Info)target).EstimateVRAM(100); string specifier = "B"; if (vramBytes > (1 << 30)) { vramBytes /= (1 << 30); specifier = "GiB"; } else if (vramBytes > (1 << 20)) { vramBytes /= (1 << 20); specifier = "MiB"; } else if (vramBytes > (1 << 10)) { vramBytes /= (1 << 10); specifier = "KiB"; } E.HelpBox( $"This configuration uses approximately {vramBytes:F1} {specifier} of VRAM", MessageType.Info); BeginHorizontal(); if (serializedObject.FindProperty(nameof(VT0Info.Modified)).boolValue) { GUI.color = Color.red; E.HelpBox("Settings were modified; apply changes before running", MessageType.None); GUI.color = Color.white; } else { E.HelpBox("No modifications", MessageType.None); } if (Button("Apply", ExpandWidth(false))) { UpdateChannelFile(); serializedObject.FindProperty(nameof(VT0Info.Modified)).boolValue = false; serializedObject.ApplyModifiedPropertiesWithoutUndo(); } EndHorizontal(); var channels = serializedObject.FindProperty(nameof(VT0Info.Channels)); for (int j = 0; j < channels.arraySize; j++) { var channel = channels.GetArrayElementAtIndex(j); BeginVertical("HelpBox"); BeginHorizontal(); Label("Channel", EditorStyles.boldLabel); var removeChannel = Button("x", Width(20f)); EndHorizontal(); E.PropertyField(channel.FindPropertyRelative(nameof(VT0Channel.Count))); BeginHorizontal(); Label("Format"); var format = channel.FindPropertyRelative(nameof(VT0Channel.Format)); E.PropertyField(format, GUIContent.none, MaxWidth(120f)); // TODO: Platform-specific formats if (Button("Opaque")) { format.intValue = (int)TextureFormat.DXT1; } if (Button("Transparent")) { format.intValue = (int)TextureFormat.DXT5; } if (Button("Alpha")) { format.intValue = (int)TextureFormat.Alpha8; } EndHorizontal(); var textureNames = channel.FindPropertyRelative(nameof(VT0Channel.TextureNames)); BeginHorizontal(); if (Button("+", Width(20f))) { textureNames.arraySize++; } Label("Property names:", EditorStyles.miniLabel); EndHorizontal(); for (int i = 0; i < textureNames.arraySize; i++) { BeginHorizontal(); var removeMe = Button("x", Width(20f)); E.PropertyField(textureNames.GetArrayElementAtIndex(i), GUIContent.none); EndHorizontal(); if (removeMe) { textureNames.DeleteArrayElementAtIndex(i--); } } E.Space(); EndVertical(); if (removeChannel) { channels.DeleteArrayElementAtIndex(j--); } } BeginHorizontal(); FlexibleSpace(); if (Button("New channel")) { channels.arraySize++; } FlexibleSpace(); EndHorizontal(); if (serializedObject.ApplyModifiedProperties()) { serializedObject.FindProperty(nameof(VT0Info.Modified)).boolValue = true; serializedObject.ApplyModifiedPropertiesWithoutUndo(); } }
public override void OnInspectorGUI() { EGL.LabelField("已有技能:"); skills = XmlManager.XmlReader.FindSkills(); for (int i = 0; i < skills.Count; i++) { EGL.BeginHorizontal(); EGL.LabelField(skills[i]); if (!tryToAddNewSkill && tryToModify == -1) { if (GUILayout.Button("修改")) { tryToModify = i; sm.LoadSkillClassInfo(skills[tryToModify]); so.Update(); } if (GUILayout.Button("删除")) { sm.DeleteSkillClass(skills[i]); so.Update(); } } EGL.EndHorizontal(); } if (tryToModify == -1 && tryToAddNewSkill == false) { EGL.Separator(); EGL.Separator(); EGL.Separator(); EGL.Separator(); if (GUILayout.Button("添加一个新技能")) { tryToAddNewSkill = true; sm.GetNewSkillTemplate(); so.Update(); } } if (tryToModify != -1) { tryToAddNewSkill = false; EGL.Separator(); EGL.Separator(); EGL.LabelField("类名: " + skills[tryToModify]); EGL.PropertyField(newSkillName, new GUIContent("技能名字")); EGL.PropertyField(resources, new GUIContent("技能预置体")); EGL.LabelField("该预置体必须处于\"Resource/SkillPerferbs\"文件夹下!"); EGL.BeginHorizontal(); EGL.PropertyField(parameterName, new GUIContent("参数名字"), true); EGL.PropertyField(parameterValue, new GUIContent("参数值"), true); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GUILayout.Button("应用")) { so.ApplyModifiedProperties(); sm.ModifySkill(skills[tryToModify]); so.Update(); tryToModify = -1; } if (GUILayout.Button("取消")) { tryToModify = -1; } EGL.EndHorizontal(); } if (tryToAddNewSkill) { EGL.Separator(); EGL.Separator(); EGL.PropertyField(newSkillClassName, new GUIContent("类名")); EGL.PropertyField(newSkillName, new GUIContent("技能名字")); EGL.PropertyField(resources, new GUIContent("技能预置体")); EGL.LabelField("该预置体必须处于\"Resource/SkillPerferbs\"文件夹下!"); EGL.BeginHorizontal(); EGL.PropertyField(parameterName, new GUIContent("参数名字"), true); EGL.PropertyField(parameterValue, new GUIContent("参数值"), true); EGL.EndHorizontal(); EGL.BeginHorizontal(); if (GUILayout.Button("应用")) { so.ApplyModifiedProperties(); if (sm.CreateNewSkillClass()) { tryToAddNewSkill = false; msg = ""; } else { msg = "请先删除重名类!或更改一个新类名"; } } if (GUILayout.Button("取消")) { tryToAddNewSkill = false; msg = ""; } EGL.EndHorizontal(); } EGL.LabelField(msg); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.PropertyField(m_Sprite, Contents.spriteLabel); EditorGUILayout.PropertyField(m_Color, Contents.colorLabel, true); FlipToggles(); Rect r = GUILayoutUtility.GetRect( EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW, EditorGUI.kSingleLineHeight, EditorGUI.kSingleLineHeight); EditorGUI.showMixedValue = m_Material.hasMultipleDifferentValues; Object currentMaterialRef = m_Material.GetArrayElementAtIndex(0).objectReferenceValue; Object returnedMaterialRef = EditorGUI.ObjectField(r, Contents.materialLabel, currentMaterialRef, typeof(Material), false); if (returnedMaterialRef != currentMaterialRef) { m_Material.GetArrayElementAtIndex(0).objectReferenceValue = returnedMaterialRef; } EditorGUI.showMixedValue = false; EditorGUILayout.PropertyField(m_DrawMode, Contents.drawModeLabel); m_ShowDrawMode.target = ShouldShowDrawMode(); if (EditorGUILayout.BeginFadeGroup(m_ShowDrawMode.faded)) { string notFullRectWarning = GetSpriteNotFullRectWarning(); if (notFullRectWarning != null) { EditorGUILayout.HelpBox(notFullRectWarning, MessageType.Warning); } EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(Contents.sizeLabel); EditorGUI.showMixedValue = m_Size.hasMultipleDifferentValues; FloatFieldLabelAbove(Contents.widthLabel, m_Size.FindPropertyRelative("x")); FloatFieldLabelAbove(Contents.heightLabel, m_Size.FindPropertyRelative("y")); EditorGUI.showMixedValue = false; EditorGUILayout.EndHorizontal(); m_ShowTileMode.target = ShouldShowTileMode(); if (EditorGUILayout.BeginFadeGroup(m_ShowTileMode.faded)) { EditorGUILayout.PropertyField(m_SpriteTileMode, Contents.fullTileLabel); m_ShowAdaptiveThreshold.target = ShouldShowAdaptiveThreshold(); if (EditorGUILayout.BeginFadeGroup(m_ShowAdaptiveThreshold.faded)) { EditorGUI.indentLevel++; EditorGUILayout.Slider(m_AdaptiveModeThreshold, 0.0f, 1.0f, Contents.fullTileThresholdLabel); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); RenderSortingLayerFields(); EditorGUILayout.PropertyField(m_MaskInteraction, Contents.maskInteractionLabel); EditorGUILayout.PropertyField(m_SpriteSortPoint, Contents.spriteSortPointLabel); RenderRenderingLayer(); CheckForErrors(); serializedObject.ApplyModifiedProperties(); }