protected override void GUI() { base.GUI(); Sprite sprite = Data.DefaultSprite; Color color = Data.DefaultColor; Image.Type imageType = Data.DefaultImageType; switch (Type) { case ImageType.Default: break; } image.sprite = sprite; image.color = color; image.type = imageType; }
public override void ModifyMesh(VertexHelper vh) { if (!IsActive()) { return; } vh.GetUIVertexStream(vertexs); int count = vertexs.Count; if (graphic is Image) { Image.Type type = (graphic as Image).type; switch (type) { case Image.Type.Simple: DrawSimple(vertexs, count); break; case Image.Type.Sliced: break; case Image.Type.Tiled: break; case Image.Type.Filled: break; } } else { DrawSimple(vertexs, count); } vh.Clear(); vh.AddUIVertexTriangleStream(vertexs); }
protected void SpriteGUI() { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_Sprite, this.m_SpriteContent, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { Sprite sprite = this.m_Sprite.objectReferenceValue as Sprite; if (sprite) { Image.Type enumValueIndex = (Image.Type) this.m_Type.enumValueIndex; if (sprite.border.SqrMagnitude() > 0f) { this.m_Type.enumValueIndex = 1; } else if (enumValueIndex == Image.Type.Sliced) { this.m_Type.enumValueIndex = 0; } } } }
protected void SpriteGUI() { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_sprite, _spriteContent); if (EditorGUI.EndChangeCheck()) { var newSprite = _sprite.objectReferenceValue as Sprite; if (newSprite) { Image.Type oldType = (Image.Type)_type.enumValueIndex; if (newSprite.border.SqrMagnitude() > 0) { _type.enumValueIndex = (int)Image.Type.Sliced; } else if (oldType == Image.Type.Sliced) { _type.enumValueIndex = (int)Image.Type.Simple; } } } }
/// <summary> /// 设置数值 /// </summary> /// <param name="newValue"></param> public void SetValue(float newValue, float oldValue = 1f, bool isSetDefaultValue = false) { newValue = Mathf.Clamp01(newValue); if (m_LerpCoroutine != null) { StopCoroutine(m_LerpCoroutine); m_LerpCoroutine = null; } if (BackSlider == null || FrontSlider == null) { Debug.LogError("UI组件缺少,不进行过渡;BackSlider:" + BackSlider + ",FrontSlider:" + FrontSlider); return; } if (FrontSlider is Image) { m_Front_Image = FrontSlider as Image; } else if (FrontSlider is Scrollbar) { m_Front_Scrollbar = FrontSlider as Scrollbar; } m_BackImageType = BackSlider.type; if (FrontSlider) { m_MaxWidth = (FrontSlider.transform as RectTransform).sizeDelta.x; } m_SliderValue = oldValue; if (isSetDefaultValue) { SetDefaultValue(); } ValueLerp(m_SliderValue, newValue); m_SliderValue = newValue; m_IsActive = true; }
public static Image AddIcon(string name, Transform parent, float width, float height, Sprite sprite = null, Image.Type type = Image.Type.Simple) { var anchorMax = new Vector2(0.5f, 0.5f); var anchorMin = new Vector2(0.5f, 0.5f); var pivot = new Vector2(0.5f, 0.5f); var sizeDelta = new Vector2(width, height); GameObject iconObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta); var img = GetOrAddComponent <Image>(iconObj); img.raycastTarget = false; img.type = type; if (sprite != null) { img.sprite = sprite; if (width == 0 || height == 0) { img.SetNativeSize(); } } return(img); }
protected virtual void UpdateSourceImage() { var m_Type = serializedObject.FindProperty("m_Type"); var m_Sprite = serializedObject.FindProperty("m_Sprite"); var spriteAtlas = _spriteAtlas.objectReferenceValue as SpriteAtlas; var newSprite = spriteAtlas?.GetSprite(_spriteName.stringValue); m_Sprite.objectReferenceValue = newSprite; // ※https://github.com/tenpn/unity3d-ui/blob/master/UnityEditor.UI/UI/ImageEditor.cs SpriteGUI()をコピー. if (newSprite) { Image.Type oldType = (Image.Type)m_Type.enumValueIndex; if (newSprite.border.SqrMagnitude() > 0) { m_Type.enumValueIndex = (int)Image.Type.Sliced; } else if (oldType == Image.Type.Sliced) { m_Type.enumValueIndex = (int)Image.Type.Simple; } } }
/// <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) { Image.Type oldType = (Image.Type)m_Type.enumValueIndex; if (newSprite.border.SqrMagnitude() > 0) { m_Type.enumValueIndex = (int)Image.Type.Sliced; } else if (oldType == Image.Type.Sliced) { m_Type.enumValueIndex = (int)Image.Type.Simple; } } (serializedObject.targetObject as Image).DisableSpriteOptimizations(); } }
private new void SpriteGUI() { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(spSprite, new GUIContent("Sprite")); if (EditorGUI.EndChangeCheck()) { Sprite newSprite = spSprite.objectReferenceValue as Sprite; if (newSprite) { Image.Type oldType = (Image.Type)spImageType.enumValueIndex; if (newSprite.border.SqrMagnitude() > 0) { spImageType.enumValueIndex = (int)Image.Type.Sliced; } else if (oldType == Image.Type.Sliced) { spImageType.enumValueIndex = (int)Image.Type.Simple; } } (serializedObject.targetObject as Image)?.DisableSpriteOptimizations(); } }
public void Reset() { m_Show = false; m_Type = SerieSymbolType.EmptyCircle; m_SizeType = SerieSymbolSizeType.Custom; m_Size = 0f; m_SelectedSize = 0f; m_DataIndex = 1; m_DataScale = 1; m_SelectedDataScale = 1.5f; m_SizeCallback = null; m_SelectedSizeCallback = null; m_StartIndex = 0; m_Interval = 0; m_ForceShowLast = false; m_Gap = 0; m_Width = 0f; m_Height = 0f; m_Repeat = false; m_Offset = Vector2.zero; m_Image = null; m_ImageType = Image.Type.Simple; }
protected void SpriteGUI() { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_Sprite, this.m_SpriteContent, new GUILayoutOption[0]); if (!EditorGUI.EndChangeCheck()) { return; } Sprite objectReferenceValue = this.m_Sprite.objectReferenceValue as Sprite; if ((bool)((UnityEngine.Object)objectReferenceValue)) { Image.Type enumValueIndex = (Image.Type) this.m_Type.enumValueIndex; if ((double)objectReferenceValue.border.SqrMagnitude() > 0.0) { this.m_Type.enumValueIndex = 1; } else if (enumValueIndex == Image.Type.Sliced) { this.m_Type.enumValueIndex = 0; } } }
public UnityRenderer(Material uiMat, TMP_FontAsset uiFont, Color linkColor, Color autolinkColor, Sprite quoteBg, Image.Type bgType, Color quoteColor, Sprite codeBg, Image.Type codeBgType, Color codeColor, Sprite inlineCodeBg, Image.Type inlineCodeBgType, Color inlineCodeColor) { UIMaterial = uiMat; UIFont = uiFont; LinkColor = linkColor; AutolinkColor = autolinkColor; QuoteBackground = quoteBg; QuoteBackgroundType = bgType; QuoteColor = quoteColor; CodeBackground = codeBg; CodeBackgroundType = codeBgType; CodeBackgroundColor = codeColor; InlineCodeBackground = inlineCodeBg; InlineCodeBackgroundType = inlineCodeBgType; InlineCodeBackgroundColor = inlineCodeColor; }
/// <summary> /// Get image properties height. /// </summary> /// <param name="imageType">Image type.</param> /// <param name="property">Property.</param> /// <returns>Height.</returns> protected static float ImagePropertiesHeight(Image.Type imageType, SerializedProperty property) { var result = 0f; var fill_method_property = property.FindPropertyRelative("FillMethod"); var fill_origin = property.FindPropertyRelative("FillOrigin"); switch (imageType) { case Image.Type.Simple: result += GetPropertyHeight(property.FindPropertyRelative("PreserveAspect")); break; case Image.Type.Sliced: result += GetPropertyHeight(property.FindPropertyRelative("FillCenter")); break; case Image.Type.Tiled: result += GetPropertyHeight(property.FindPropertyRelative("FillCenter")); break; case Image.Type.Filled: result += GetPropertyHeight(fill_method_property); result += GetPropertyHeight(fill_origin); result += GetPropertyHeight(property.FindPropertyRelative("FillAmount")); var fill_method = (Image.FillMethod)fill_method_property.enumValueIndex; if (fill_method == Image.FillMethod.Radial90 || fill_method == Image.FillMethod.Radial180 || fill_method == Image.FillMethod.Radial360) { result += GetPropertyHeight(property.FindPropertyRelative("FillClockwise")); } result += GetPropertyHeight(property.FindPropertyRelative("PreserveAspect")); break; } return(result); }
public GameObject CreateButton(string name, Transform parent, Vector2 _sizeDelta, Vector2 _anchorMin, Vector2 _anchorMax, Vector3 _localScale, Vector2 _pivot, Vector2 _anchoredPosition, Sprite _sprite, Image.Type type) { GameObject button = new GameObject(name); button.transform.SetParent(parent); button.AddComponent <RectTransform>(); button.AddComponent <Image>(); button.AddComponent <Button>(); //Set RectTransform button.GetComponent <RectTransform>().sizeDelta = _sizeDelta; button.GetComponent <RectTransform>().anchorMin = _anchorMin; button.GetComponent <RectTransform>().anchorMax = _anchorMax; button.GetComponent <RectTransform>().localScale = _localScale; button.GetComponent <RectTransform>().pivot = _pivot; button.GetComponent <RectTransform>().anchoredPosition = _anchoredPosition; //Set Image button.GetComponent <Image>().sprite = _sprite; button.GetComponent <Image>().type = type; return(button); }
public GameObject CreateImage(string name, Transform parent, Vector2 _sizeDelta, Vector2 _anchorMin, Vector2 _anchorMax, Vector3 _localScale, Vector2 _pivot, Vector2 _anchoredPosition, Vector3 _localPosition, Sprite _sprite, Image.Type type, Color32 _color) { GameObject image = new GameObject(name); image.transform.SetParent(parent); image.AddComponent <RectTransform>(); image.AddComponent <Image>(); //Set RectTransform image.GetComponent <RectTransform>().localPosition = _localPosition; image.GetComponent <RectTransform>().sizeDelta = _sizeDelta; image.GetComponent <RectTransform>().anchorMin = _anchorMin; image.GetComponent <RectTransform>().anchorMax = _anchorMax; image.GetComponent <RectTransform>().localScale = _localScale; image.GetComponent <RectTransform>().pivot = _pivot; image.GetComponent <RectTransform>().anchoredPosition = _anchoredPosition; //Set Image image.GetComponent <Image>().color = _color; image.GetComponent <Image>().sprite = _sprite; image.GetComponent <Image>().type = type; return(image); }
void SetShowNativeSize(bool instant) { Image.Type type = (Image.Type)m_Type.enumValueIndex; bool showNativeSize = (type == Image.Type.Simple || type == Image.Type.Filled) && !CheckSpriteIsNull(m_Sprite); base.SetShowNativeSize(showNativeSize, instant); }
private static GameObject CreateMaskTemplate(string name, RectTransform target, Sprite img, Image.FillMethod fillMethod, Image.Type type = Image.Type.Filled) { var mask_m = new GameObject(name + "template", typeof(RectTransform), typeof(Mask), typeof(Image)); mask_m.transform.SetParent(target.parent); mask_m.GetComponent <Image>().type = type; mask_m.GetComponent <Image>().fillMethod = fillMethod; mask_m.GetComponent <Image>().sprite = img; mask_m.GetComponent <Mask>().showMaskGraphic = false; return(mask_m); }
static void SetImage(Image image, string resource, Color color, Vector2 size, Image.Type type) { image.sprite = AssetDatabase.GetBuiltinExtraResource <Sprite>(resource); image.color = color; (image.transform as RectTransform).sizeDelta = size; image.type = type; }
public void setImageType(Image.Type type) { _btn.GetComponent <Image>().type = type; }
protected void TypeGUI() { EditorGUILayout.PropertyField(this.m_Type, this.m_SpriteTypeContent, new GUILayoutOption[0]); EditorGUI.indentLevel++; Image.Type enumValueIndex = (Image.Type) this.m_Type.enumValueIndex; bool flag = !this.m_Type.hasMultipleDifferentValues && (enumValueIndex == Image.Type.Sliced || enumValueIndex == Image.Type.Tiled); if (flag && base.targets.Length > 1) { flag = (from obj in base.targets select obj as Image).All((Image img) => img.hasBorder); } this.m_ShowSlicedOrTiled.target = flag; this.m_ShowSliced.target = (flag && !this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Sliced); this.m_ShowTiled.target = (flag && !this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Tiled); this.m_ShowFilled.target = (!this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Filled); Image image = base.target as Image; if (EditorGUILayout.BeginFadeGroup(this.m_ShowSlicedOrTiled.faded)) { if (image.hasBorder) { EditorGUILayout.PropertyField(this.m_FillCenter, new GUILayoutOption[0]); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.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(this.m_ShowTiled.faded)) { if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed)) { EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to convert the Sprite to an Advanced texture, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning); } } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_ShowFilled.faded)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_FillMethod, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { this.m_FillOrigin.intValue = 0; } switch (this.m_FillMethod.enumValueIndex) { case 0: this.m_FillOrigin.intValue = (int)((Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginHorizontal) this.m_FillOrigin.intValue, new GUILayoutOption[0])); break; case 1: this.m_FillOrigin.intValue = (int)((Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Image.OriginVertical) this.m_FillOrigin.intValue, new GUILayoutOption[0])); break; case 2: this.m_FillOrigin.intValue = (int)((Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin90) this.m_FillOrigin.intValue, new GUILayoutOption[0])); break; case 3: this.m_FillOrigin.intValue = (int)((Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin180) this.m_FillOrigin.intValue, new GUILayoutOption[0])); break; case 4: this.m_FillOrigin.intValue = (int)((Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Image.Origin360) this.m_FillOrigin.intValue, new GUILayoutOption[0])); break; } EditorGUILayout.PropertyField(this.m_FillAmount, new GUILayoutOption[0]); if (this.m_FillMethod.enumValueIndex > 1) { EditorGUILayout.PropertyField(this.m_FillClockwise, this.m_ClockwiseContent, new GUILayoutOption[0]); } } EditorGUILayout.EndFadeGroup(); EditorGUI.indentLevel--; }
UnityRendererBuilder IInlineCodeRendererBuilder.UseBackground(Sprite bg, Image.Type type) { _codeInlineBg = bg; _codeInlineBgType = type; return(this); }
/// <summary> /// Sprites's custom properties based on the type. /// </summary> protected void ProceduralImageTypeGUI() { if (m_Type.hasMultipleDifferentValues) { int idx = Convert.ToInt32(EditorGUILayout.EnumPopup(spriteTypeContent, (ProceduralImageType)(-1))); if (idx != -1) { m_Type.enumValueIndex = idx; } } else { m_Type.enumValueIndex = Convert.ToInt32(EditorGUILayout.EnumPopup(spriteTypeContent, (ProceduralImageType)m_Type.enumValueIndex)); } ++EditorGUI.indentLevel; { Image.Type typeEnum = (Image.Type)m_Type.enumValueIndex; showFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Filled); if (EditorGUILayout.BeginFadeGroup(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, clockwiseContent); } } EditorGUILayout.EndFadeGroup(); } --EditorGUI.indentLevel; }
public void SetSpriteType(Image.Type type) { imageType = type; }
/// <summary> /// Sprites's custom properties based on the type. /// </summary> protected void TypeGUI() { EditorGUILayout.PropertyField(m_Type, m_SpriteTypeContent); ++EditorGUI.indentLevel; { Image.Type typeEnum = (Image.Type)m_Type.enumValueIndex; bool showSlicedOrTiled = (!m_Type.hasMultipleDifferentValues && (typeEnum == Image.Type.Sliced || typeEnum == Image.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 == Image.Type.Sliced); m_ShowTiled.target = (showSlicedOrTiled && !m_Type.hasMultipleDifferentValues && typeEnum == Image.Type.Tiled); m_ShowFilled.target = (!m_Type.hasMultipleDifferentValues && typeEnum == Image.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_ShowTiled.faded)) { if (image.sprite != null && !image.hasBorder && (image.sprite.texture.wrapMode != TextureWrapMode.Repeat || image.sprite.packed)) { EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to modify the Sprite properties, clear the Packing tag and set the Wrap mode to Repeat.", 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; }
public UnsupportedImageType(GameObject objectBeingConverted, Image.Type unsupportedType) { this.objectBeingConverted = objectBeingConverted; this.unsupportedType = unsupportedType; }
public static Image InstantiateImage(Transform parent, Sprite sprite, Color color, Image.Type type) { GameObject go = new GameObject(); go.transform.SetParent(parent); Image i = AddImage(go, sprite, color, type); return(i); }
UnityRendererBuilder IQuoteRendererBuilder.UseBackground(Sprite bg, Image.Type type) { _quoteBg = bg; _quoteBgType = type; return(this); }
public override void OnInspectorGUI() { serializedObject.Update(); if (atlasProperty != null) { using (EditorGUILayout.HorizontalScope horizontalScope = new EditorGUILayout.HorizontalScope()) { if (GUILayout.Button("Atlas", "DropDown", GUILayout.Width(EditorGUIUtility.labelWidth - 10)) == true) { AtlasSelector.Show(null, OnDoubleClickAtlas, atlasProperty.objectReferenceValue as UGUIAtlas); } //绘制图集属性 UGUIAtlas selectedAtlas = EditorGUILayout.ObjectField(atlasProperty.objectReferenceValue, typeof(UGUIAtlas), true) as UGUIAtlas; if (selectedAtlas != atlasProperty.objectReferenceValue) { atlasProperty.objectReferenceValue = selectedAtlas; spriteProperty.objectReferenceValue = null; serializedObject.ApplyModifiedProperties(); } } using (EditorGUILayout.HorizontalScope horizontalScope = new EditorGUILayout.HorizontalScope()) { var atlas = atlasProperty.objectReferenceValue as UGUIAtlas; if (atlas != null) { if (GUILayout.Button("Sprite", "DropDown", GUILayout.Width(EditorGUIUtility.labelWidth - 10)) == true) { AtlasSpriteSelector.Show(atlas, OnClickSprite, OnDoubleClickSprite, spriteProperty.objectReferenceValue as Sprite); } } else { GUILayout.Label("Sprite", GUILayout.Width(EditorGUIUtility.labelWidth - 10)); } using (EditorGUI.DisabledScope disableGroup = new EditorGUI.DisabledScope(atlas != null)) { using (EditorGUI.ChangeCheckScope changeCheckScope = new EditorGUI.ChangeCheckScope()) { EditorGUILayout.PropertyField(spriteProperty, new GUIContent("")); if (changeCheckScope.changed == true) { var newSprite = spriteProperty.objectReferenceValue as Sprite; if (newSprite) { Image.Type oldType = (Image.Type)typeProperty.enumValueIndex; if (newSprite.border.SqrMagnitude() > 0) { typeProperty.enumValueIndex = (int)Image.Type.Sliced; } else if (oldType == Image.Type.Sliced) { typeProperty.enumValueIndex = (int)Image.Type.Simple; } } } serializedObject.ApplyModifiedProperties(); } } } AppearanceControlsGUI(); RaycastControlsGUI(); showType.target = spriteProperty.objectReferenceValue != null; if (EditorGUILayout.BeginFadeGroup(showType.faded)) { TypeGUI(); } EditorGUILayout.EndFadeGroup(); SetShowNativeSize(true, true); if (EditorGUILayout.BeginFadeGroup(m_ShowNativeSize.faded)) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(preserveAspectProperty); EditorGUI.indentLevel--; } EditorGUILayout.EndFadeGroup(); NativeSizeButtonGUI(); serializedObject.ApplyModifiedProperties(); } }
// Тип имейджа public void set_type(Image.Type type) { image.type = type; }
protected void TypeGUI() { EditorGUILayout.PropertyField(this.m_Type, this.m_SpriteTypeContent, new GUILayoutOption[0]); ++EditorGUI.indentLevel; Image.Type enumValueIndex = (Image.Type) this.m_Type.enumValueIndex; bool flag = !this.m_Type.hasMultipleDifferentValues && (enumValueIndex == Image.Type.Sliced || enumValueIndex == Image.Type.Tiled); this.m_ShowSlicedOrTiled.target = flag; this.m_ShowSliced.target = flag && !this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Sliced; this.m_ShowTiled.target = flag && !this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Tiled; this.m_ShowFilled.target = !this.m_Type.hasMultipleDifferentValues && enumValueIndex == Image.Type.Filled; UIImageData target = this.target as UIImageData; if (EditorGUILayout.BeginFadeGroup(this.m_ShowSlicedOrTiled.faded)) { EditorGUILayout.PropertyField(this.m_FillCenter); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_ShowSliced.faded) && target.m_Sprite != (UnityEngine.Object)null) { EditorGUILayout.HelpBox("This Image doesn't have a border.", MessageType.Warning); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_ShowTiled.faded) && (UnityEngine.Object)target.m_Sprite != (UnityEngine.Object)null && (target.m_Sprite.texture.wrapMode != TextureWrapMode.Repeat || target.m_Sprite.packed)) { EditorGUILayout.HelpBox("It looks like you want to tile a sprite with no border. It would be more efficient to convert the Sprite to an Advanced texture, clear the Packing tag and set the Wrap mode to Repeat.", MessageType.Warning); } EditorGUILayout.EndFadeGroup(); if (EditorGUILayout.BeginFadeGroup(this.m_ShowFilled.faded)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(this.m_FillMethod); if (EditorGUI.EndChangeCheck()) { this.m_FillOrigin.intValue = 0; } switch ((int)(Image.FillMethod) this.m_FillMethod.enumValueIndex) { case 0: this.m_FillOrigin.intValue = (int)(Image.OriginHorizontal)EditorGUILayout.EnumPopup("Fill Origin", (Enum)(object)(Image.OriginHorizontal) this.m_FillOrigin.intValue, new GUILayoutOption[0]); break; case 1: this.m_FillOrigin.intValue = (int)(Image.OriginVertical)EditorGUILayout.EnumPopup("Fill Origin", (Enum)(object)(Image.OriginVertical) this.m_FillOrigin.intValue, new GUILayoutOption[0]); break; case 2: this.m_FillOrigin.intValue = (int)(Image.Origin90)EditorGUILayout.EnumPopup("Fill Origin", (Enum)(object)(Image.Origin90) this.m_FillOrigin.intValue, new GUILayoutOption[0]); break; case 3: this.m_FillOrigin.intValue = (int)(Image.Origin180)EditorGUILayout.EnumPopup("Fill Origin", (Enum)(object)(Image.Origin180) this.m_FillOrigin.intValue, new GUILayoutOption[0]); break; case 4: this.m_FillOrigin.intValue = (int)(Image.Origin360)EditorGUILayout.EnumPopup("Fill Origin", (Enum)(object)(Image.Origin360) this.m_FillOrigin.intValue, new GUILayoutOption[0]); break; } EditorGUILayout.PropertyField(this.m_FillAmount); if (this.m_FillMethod.enumValueIndex > 1) { EditorGUILayout.PropertyField(this.m_FillClockwise, this.m_ClockwiseContent, new GUILayoutOption[0]); } } EditorGUILayout.EndFadeGroup(); --EditorGUI.indentLevel; }