void SetShowNativeSize(bool instant) { if (m_Texture.objectReferenceValue == null) { base.SetShowNativeSize(false, instant); return; } FillableRawImage.Type type = (FillableRawImage.Type)m_Type.enumValueIndex; bool showNativeSize = (type == FillableRawImage.Type.Simple || type == FillableRawImage.Type.Filled); base.SetShowNativeSize(showNativeSize, instant); }
// public override void OnInspectorGUI() // { // serializedObject.Update(); // // SpriteGUI(); // AppearanceControlsGUI(); // RaycastControlsGUI(); // //// m_ShowType.target = m_Sprite.objectReferenceValue != null; // m_ShowType.target = m_Texture.objectReferenceValue != null; // // // if (EditorGUILayout.BeginFadeGroup(m_ShowType.faded)) // TypeGUI(); // EditorGUILayout.EndFadeGroup(); // // SetShowNativeSize(false); // if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) // { // EditorGUI.indentLevel++; // EditorGUILayout.PropertyField(m_PreserveAspect); // EditorGUI.indentLevel--; // } // EditorGUILayout.EndFadeGroup(); // NativeSizeButtonGUI(); // // serializedObject.ApplyModifiedProperties(); // } // void SetShowNativeSize(bool instant) // { // FillableRawImage.Type type = (FillableRawImage.Type)m_Type.enumValueIndex; // bool showNativeSize = (type == FillableRawImage.Type.Simple || type == FillableRawImage.Type.Filled); // base.SetShowNativeSize(showNativeSize, instant); // } /// <summary> /// Draw the atlas and Image selection fields. /// </summary> // protected void SpriteGUI() // { // EditorGUI.BeginChangeCheck(); // //// EditorGUILayout.PropertyField(m_Sprite, m_SpriteContent); // // if (EditorGUI.EndChangeCheck()) // { // var newSprite = m_Sprite.objectReferenceValue as Sprite; // if (newSprite) // { // FillableRawImage.Type oldType = (FillableRawImage.Type)m_Type.enumValueIndex; // if (newSprite.border.SqrMagnitude() > 0) // { // m_Type.enumValueIndex = (int)FillableRawImage.Type.Sliced; // } // else if (oldType == FillableRawImage.Type.Sliced) // { // m_Type.enumValueIndex = (int)FillableRawImage.Type.Simple; // } // } // } // } /// <summary> /// Sprites's custom properties based on the type. /// </summary> protected void TypeGUI() { EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent); ++EditorGUI.indentLevel; { FillableRawImage.Type typeEnum = (FillableRawImage.Type)m_Type.enumValueIndex; bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == FillableRawImage.Type.Sliced || typeEnum == FillableRawImage.Type.Tiled)); if (showSlicedOrTiled && targets.Length > 1) { showSlicedOrTiled = targets.Select(obj => obj as Image).All(img => img.hasBorder); } m_ShowSlicedOrTiled.target = showSlicedOrTiled; m_ShowSliced.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == FillableRawImage.Type.Sliced); m_ShowFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == FillableRawImage.Type.Filled); Image image = target as Image; if (EditorGUILayout.BeginFadeGroup(m_ShowSlicedOrTiled.faded)) { if (image.hasBorder) { EditorGUILayout.PropertyField(m_FillCenter); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowSliced.faded)) { if (image.sprite != null && !image.hasBorder) { EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(m_ShowFilled.faded)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(m_FillMethod); if (EditorGUI.EndChangeCheck()) { m_FillOrigin.intValue = 0; } switch ((Image.FillMethod)m_FillMethod.enumValueIndex) { case Image.FillMethod.Horizontal: m_FillOrigin.intValue = (int)(Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginHorizontal)m_FillOrigin.intValue); break; case Image.FillMethod.Vertical: m_FillOrigin.intValue = (int)(Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginVertical)m_FillOrigin.intValue); break; case Image.FillMethod.Radial90: m_FillOrigin.intValue = (int)(Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin90)m_FillOrigin.intValue); break; case Image.FillMethod.Radial180: m_FillOrigin.intValue = (int)(Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin180)m_FillOrigin.intValue); break; case Image.FillMethod.Radial360: m_FillOrigin.intValue = (int)(Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin360)m_FillOrigin.intValue); break; } EditorGUILayout.PropertyField(m_FillAmount); if ((Image.FillMethod)m_FillMethod.enumValueIndex > Image.FillMethod.Vertical) { EditorGUILayout.PropertyField(m_FillClockwise, m_ClockwiseContent); } } EditorGUILayout.EndFadeGroup(); } --EditorGUI.indentLevel; }