public static int SetBorder(IntPtr l) { int result; try { UISpriteData uISpriteData = (UISpriteData)LuaObject.checkSelf(l); int left; LuaObject.checkType(l, 2, out left); int bottom; LuaObject.checkType(l, 3, out bottom); int right; LuaObject.checkType(l, 4, out right); int top; LuaObject.checkType(l, 5, out top); uISpriteData.SetBorder(left, bottom, right, top); LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
private UISpriteData ClipAtlasSprite(UISpriteData originSprite) { if (isLoadHeroHead) { return(null); } if (originSprite == null) { return(null); } if (mClipType != eClipType.None && type == Type.Simple) { UISpriteData clip_sprite = mSwapSprite; clip_sprite.CopyFrom(originSprite); clip_sprite.SetBorder(0, 0, 0, 0); clip_sprite.SetPadding(0, 0, 0, 0); if (mClipType == eClipType.Horizontally) { int keep_aspect_width = Mathf.RoundToInt((float)width / height * clip_sprite.height); int w = clip_sprite.width - keep_aspect_width; if (w < 0) { clip_sprite.SetRect(clip_sprite.x, clip_sprite.y, clip_sprite.width, clip_sprite.height); int padding = -w / 2; clip_sprite.SetPadding(padding, 0, padding, 0); } else { clip_sprite.SetRect(clip_sprite.x + w / 2, clip_sprite.y, keep_aspect_width, clip_sprite.height); } } else if (mClipType == eClipType.Vertically) { int keep_aspect_height = Mathf.RoundToInt((float)height / width * clip_sprite.width); int h = clip_sprite.height - keep_aspect_height; if (h < 0) { clip_sprite.SetRect(clip_sprite.x, clip_sprite.y, clip_sprite.width, clip_sprite.height); int padding = -h / 2; clip_sprite.SetPadding(padding, 0, padding, 0); } else { clip_sprite.SetRect(clip_sprite.x, clip_sprite.y + h / 2, clip_sprite.width, keep_aspect_height); } } return(clip_sprite); } else { UISpriteData clip_sprite = mSwapSprite; clip_sprite.CopyFrom(originSprite); return(clip_sprite); } }
static int SetBorder(IntPtr L) { try { ToLua.CheckArgsCount(L, 5); UISpriteData obj = (UISpriteData)ToLua.CheckObject(L, 1, typeof(UISpriteData)); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); int arg2 = (int)LuaDLL.luaL_checknumber(L, 4); int arg3 = (int)LuaDLL.luaL_checknumber(L, 5); obj.SetBorder(arg0, arg1, arg2, arg3); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int SetBorder(IntPtr l) { try { UISpriteData self = (UISpriteData)checkSelf(l); System.Int32 a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); System.Int32 a3; checkType(l, 4, out a3); System.Int32 a4; checkType(l, 5, out a4); self.SetBorder(a1, a2, a3, a4); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
protected override bool ShouldDrawProperties() { if (target == null) { return(false); } if (Application.isPlaying == false && NGUIEditorTools.DrawHeader("Tex to Spr")) { NGUIEditorTools.BeginContents(); GUILayout.BeginHorizontal(); if (NGUIEditorTools.DrawPrefixButton("Atlas")) { ComponentSelector.Show <UIAtlas>(OnSelectAtlas); } UIAtlas curAtlas = NGUISettings.atlas; if (curAtlas != null) { GUILayout.Label(curAtlas.name, "HelpBox", GUILayout.Height(18f)); } else { GUILayout.Label("No Atlas", "HelpBox", GUILayout.Height(18f)); } GUILayout.FlexibleSpace(); if (GUILayout.Button("ToS", GUILayout.Width(40f))) { if (curAtlas == null) { CreateOwnAtlas(); curAtlas = NGUISettings.atlas; } List <UIAtlasMaker.SpriteEntry> entries = UIAtlasMaker.CreateSprites(new List <Texture>() { mTex.mainTexture }); UIAtlasMaker.ExtractSprites(curAtlas, entries); UIAtlasMaker.UpdateAtlas(curAtlas, entries); UISprite sprite = mTex.gameObject.AddComponent <UISprite>(); sprite.atlas = curAtlas; sprite.spriteName = mTex.mainTexture.name; sprite.type = mTex.type; UISpriteData data = sprite.GetAtlasSprite(); data.SetBorder((int)mTex.border.w, (int)mTex.border.y, (int)mTex.border.x, (int)mTex.border.z); sprite.depth = mTex.depth; sprite.width = mTex.width; sprite.height = mTex.height; UITexture.DestroyImmediate(mTex); EditorGUIUtility.ExitGUI(); return(false); } GUILayout.EndHorizontal(); NGUIEditorTools.EndContents(); } SerializedProperty sp = NGUIEditorTools.DrawProperty("Texture", serializedObject, "mTexture"); NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat"); if (sp != null) { NGUISettings.texture = sp.objectReferenceValue as Texture; } if (mTex != null && (mTex.material == null || serializedObject.isEditingMultipleObjects)) { NGUIEditorTools.DrawProperty("Shader", serializedObject, "mShader"); } EditorGUI.BeginDisabledGroup(mTex == null || mTex.mainTexture == null || serializedObject.isEditingMultipleObjects); NGUIEditorTools.DrawRectProperty("UV Rect", serializedObject, "mRect"); sp = serializedObject.FindProperty("mFixedAspect"); bool before = sp.boolValue; NGUIEditorTools.DrawProperty("Fixed Aspect", sp); if (sp.boolValue != before) { (target as UIWidget).drawRegion = new Vector4(0f, 0f, 1f, 1f); } if (sp.boolValue) { EditorGUILayout.HelpBox("Note that Fixed Aspect mode is not compatible with Draw Region modifications done by sliders and progress bars.", MessageType.Info); } EditorGUI.EndDisabledGroup(); return(true); }