public void IntField(ref UndoParentNode owner, string content) { if (!m_active) { EditorGUILayout.BeginHorizontal(); m_value = owner.EditorGUILayoutIntField(content, (int)m_value); if (GUILayout.Button(UIUtils.FloatIntIconON, UIUtils.FloatIntPickerONOFF, GUILayout.Width(15), GUILayout.Height(15))) { m_active = !m_active; } EditorGUILayout.EndHorizontal(); } else { DrawPicker(ref owner, content); } }
public void Draw(UndoParentNode owner) { if (m_isVisible) { int lastOption = m_currentOption; EditorGUI.BeginChangeCheck(); switch (m_options.UIWidget) { case AseOptionsUIWidget.Dropdown: { m_currentOption = owner.EditorGUILayoutPopup(m_options.Name, m_currentOption, m_options.DisplayOptions); } break; case AseOptionsUIWidget.Toggle: { m_currentOption = owner.EditorGUILayoutToggle(m_options.Name, m_currentOption == 1) ? 1 : 0; } break; case AseOptionsUIWidget.Float: { if (m_options.FieldInline) { m_options.FieldValue.FloatField(ref owner, m_options.Name); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutFloatField(m_options.Name, m_options.FieldValue.FloatValue); } } break; case AseOptionsUIWidget.Int: { if (m_options.FieldInline) { m_options.FieldValue.IntField(ref owner, m_options.Name); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutIntField(m_options.Name, (int)m_options.FieldValue.FloatValue); } } break; case AseOptionsUIWidget.FloatRange: { if (m_options.FieldInline) { m_options.FieldValue.SliderField(ref owner, m_options.Name, m_options.FieldMin, m_options.FieldMax); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutSlider(m_options.Name, m_options.FieldValue.FloatValue, m_options.FieldMin, m_options.FieldMax); } } break; case AseOptionsUIWidget.IntRange: { if (m_options.FieldInline) { m_options.FieldValue.IntSlider(ref owner, m_options.Name, (int)m_options.FieldMin, (int)m_options.FieldMax); if (m_options.FieldValue.Active) { m_currentOption = 1; } else { m_currentOption = 0; } } else { m_options.FieldValue.FloatValue = owner.EditorGUILayoutIntSlider(m_options.Name, (int)m_options.FieldValue.FloatValue, (int)m_options.FieldMin, (int)m_options.FieldMax); } } break; } if (EditorGUI.EndChangeCheck()) { if (OnActionPerformedEvt != null) { if (m_invertActionOnDeselection) { OnActionPerformedEvt(false, lastOption != m_options.DisableIdx, this, m_options.ActionsPerOption[lastOption]); } OnActionPerformedEvt(false, false, this, m_options.ActionsPerOption[m_currentOption]); } } } }
public void ShowInternalData(UndoParentNode owner, bool useCustomLabel = false, string customLabel = null) { string label = (useCustomLabel == true && customLabel != null) ? customLabel : m_internalDataPropertyLabel; switch (m_dataType) { case WirePortDataType.OBJECT: case WirePortDataType.FLOAT: { FloatInternalData = owner.EditorGUILayoutFloatField(label, FloatInternalData); } break; case WirePortDataType.FLOAT2: { Vector2InternalData = owner.EditorGUILayoutVector2Field(label, Vector2InternalData); } break; case WirePortDataType.FLOAT3: { Vector3InternalData = owner.EditorGUILayoutVector3Field(label, Vector3InternalData); } break; case WirePortDataType.FLOAT4: { Vector4InternalData = owner.EditorGUILayoutVector4Field(label, Vector4InternalData); } break; case WirePortDataType.FLOAT3x3: { Matrix4x4 matrix = Matrix4x4InternalData; Vector3 currVec3 = Vector3.zero; for (int i = 0; i < 3; i++) { Vector4 currVec = matrix.GetRow(i); currVec3.Set(currVec.x, currVec.y, currVec.z); EditorGUI.BeginChangeCheck(); currVec3 = owner.EditorGUILayoutVector3Field(label + "[ " + i + " ]", currVec3); if (EditorGUI.EndChangeCheck()) { currVec.Set(currVec3.x, currVec3.y, currVec3.z, currVec.w); matrix.SetRow(i, currVec); } } Matrix4x4InternalData = matrix; } break; case WirePortDataType.FLOAT4x4: { Matrix4x4 matrix = Matrix4x4InternalData; for (int i = 0; i < 4; i++) { Vector4 currVec = matrix.GetRow(i); EditorGUI.BeginChangeCheck(); currVec = owner.EditorGUILayoutVector4Field(label + "[ " + i + " ]", currVec); if (EditorGUI.EndChangeCheck()) { matrix.SetRow(i, currVec); } } Matrix4x4InternalData = matrix; } break; case WirePortDataType.COLOR: { ColorInternalData = owner.EditorGUILayoutColorField(label, ColorInternalData); } break; case WirePortDataType.INT: { IntInternalData = owner.EditorGUILayoutIntField(label, IntInternalData); } break; } }
void DrawMainBody() { EditorGUI.BeginChangeCheck(); { EditorGUILayout.Separator(); int itemCount = m_availableTags.Count; if (itemCount == 0) { EditorGUILayout.HelpBox("Your list is Empty!\nUse the plus button to add one.", MessageType.Info); } int markedToDelete = -1; float originalLabelWidth = EditorGUIUtility.labelWidth; for (int i = 0; i < itemCount; i++) { m_availableTags[i].TagFoldout = m_currentOwner.EditorGUILayoutFoldout(m_availableTags[i].TagFoldout, string.Format("[{0}] - {1}", i, m_availableTags[i].TagName)); if (m_availableTags[i].TagFoldout) { EditorGUI.indentLevel += 1; EditorGUIUtility.labelWidth = 70; //Tag Name EditorGUI.BeginChangeCheck(); m_availableTags[i].TagName = m_currentOwner.EditorGUILayoutTextField(TagNameStr, m_availableTags[i].TagName); if (EditorGUI.EndChangeCheck()) { m_availableTags[i].TagName = UIUtils.RemoveShaderInvalidCharacters(m_availableTags[i].TagName); m_tagNameCheckFlag = true; m_tagNameCheckItemId = i; m_tagNameCheckTimestamp = EditorApplication.timeSinceStartup; } //Tag Value switch (m_availableTags[i].SpecialTag) { case TemplateSpecialTags.DisableBatching: { m_availableTags[i].Batching = (DisableBatching)m_currentOwner.EditorGUILayoutEnumPopup(RenderTypeLabelStr, m_availableTags[i].Batching); m_availableTags[i].TagValue = m_availableTags[i].Batching.ToString(); } break; case TemplateSpecialTags.RenderType: { m_availableTags[i].RenderType = (RenderType)m_currentOwner.EditorGUILayoutEnumPopup(RenderTypeLabelStr, m_availableTags[i].RenderType); if (m_availableTags[i].RenderType == RenderType.Custom) { m_availableTags[i].TagValue = m_currentOwner.EditorGUILayoutTextField(CustomRenderTypeLabelStr, m_availableTags[i].TagValue); } } break; case TemplateSpecialTags.Queue: { EditorGUI.BeginChangeCheck(); m_availableTags[i].RenderQueue = (RenderQueue)m_currentOwner.EditorGUILayoutEnumPopup(QueueLabelStr, m_availableTags[i].RenderQueue, GUILayout.MinWidth(150)); m_availableTags[i].RenderQueueOffset = m_currentOwner.EditorGUILayoutIntField(QueueIndexStr, m_availableTags[i].RenderQueueOffset); if (EditorGUI.EndChangeCheck()) { m_availableTags[i].BuildQueueTagValue(); } } break; case TemplateSpecialTags.None: { EditorGUI.BeginChangeCheck(); m_availableTags[i].TagValue = m_currentOwner.EditorGUILayoutTextField(TagValueStr, m_availableTags[i].TagValue); if (EditorGUI.EndChangeCheck()) { m_availableTags[i].TagValue = UIUtils.RemoveShaderInvalidCharacters(m_availableTags[i].TagValue); } } break; } EditorGUIUtility.labelWidth = originalLabelWidth; EditorGUILayout.BeginHorizontal(); { GUILayout.Label(" "); // Add new port if (m_currentOwner.GUILayoutButton(string.Empty, UIUtils.PlusStyle, GUILayout.Width(ShaderKeywordButtonLayoutWidth))) { m_availableTags.Insert(i + 1, new CustomTagData()); EditorGUI.FocusTextInControl(null); } //Remove port if (m_currentOwner.GUILayoutButton(string.Empty, UIUtils.MinusStyle, GUILayout.Width(ShaderKeywordButtonLayoutWidth))) { markedToDelete = i; } } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel -= 1; } } if (markedToDelete > -1) { if (m_availableTags.Count > markedToDelete) { m_availableTags.RemoveAt(markedToDelete); EditorGUI.FocusTextInControl(null); } } EditorGUILayout.Separator(); } if (EditorGUI.EndChangeCheck()) { m_isDirty = true; } }