本文整理汇总了C#中UISprite.positionFromTopLeft方法的典型用法代码示例。如果您正苦于以下问题:C# UISprite.positionFromTopLeft方法的具体用法?C# UISprite.positionFromTopLeft怎么用?C# UISprite.positionFromTopLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UISprite
的用法示例。
在下文中一共展示了UISprite.positionFromTopLeft方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UIPeaceMakerActor
//constructor
public UIPeaceMakerActor(UIToolkit toolkit, string actorName, string fileName)
{
//todo make this scalable
_height = 50; //background image size
_width = 50;
_touchFrame = new Rect ( position.x, -position.y, _width, _height );
//background image is always the same
_actorBackground = toolkit.addSprite("actorBG.png", 0, 0);
_actorBackground.parentUIObject = this;
_actorBackground.positionFromTopLeft (0f, 0f);
//gradient is always the same
_actorGradient = toolkit.addSprite ("actor_gradient_white.png", 0, 0);
_actorGradient.parentUIObject = this;
_actorGradient.positionFromTopLeft (0f, 0f);
//image and button
_theButton = UIButton.create (toolkit, fileName, fileName, 0, 0);
_theButton.parentUIObject = this;
_theButton.onTouchUpInside += ( sender ) => randomAttitudeTest ();
//up/down arrow is always the same
_actorArrow = toolkit.addSprite ("up_arrow_anim_00.png", 0, 0);
_actorArrow.parentUIObject = this;
_actorArrow.positionFromTopRight (0f, 0f);
_arrowUpAnim = _actorArrow.addSpriteAnimation ("arrowUpAnim", 0.1f, "up_arrow_anim_00.png", "up_arrow_anim_01.png", "up_arrow_anim_02.png", "up_arrow_anim_03.png", "up_arrow_anim_04.png", "up_arrow_anim_05.png", "up_arrow_anim_06.png", "up_arrow_anim_07.png", "up_arrow_anim_08.png", "up_arrow_anim_09.png");
_arrowDownAnim = _actorArrow.addSpriteAnimation ("arrowDownAnim", 0.1f, "down_arrow_anim_00.png", "down_arrow_anim_01.png", "down_arrow_anim_02.png", "down_arrow_anim_03.png", "down_arrow_anim_04.png", "down_arrow_anim_05.png", "down_arrow_anim_06.png", "down_arrow_anim_07.png", "down_arrow_anim_08.png", "down_arrow_anim_09.png");
_arrowUpAnim.loopReverse = true;
_arrowDownAnim.loopReverse = true;
hideAttitudeIndicators ();
}
示例2: Start
public void Start ()
{
// @ see http://forum.unity3d.com/threads/87917-Prime31-UIToolkit-Multi-Resolution-GUI-Solution-Ready-for-Use-and-it-s-free/page79
// @ see http://timshaya.wordpress.com/category/uitoolkit/
//var in_game_hud = GameObject.Find("in_game_hud").GetComponent<UIToolkit>();
//var map = UIButton.create(in_game_hud, "skills.png", "skills.png", 100, 100);
//map.centerize();
var atlas = GameObject.Find("network_atlas").GetComponent<UIToolkit>();
var padding = 0.00f;
disconnected = atlas.addSprite("disconnected.png", 0, 0);
disconnected.positionFromTopLeft(padding, 0.2f);
disconnected.color = Color.white;
connected = atlas.addSprite("connected.png", 0, 0);
connected.positionFromTopLeft(padding, 0.23f);
connected.color = Color.grey;
activity = atlas.addSprite("activity.png", 0, 0);
activity.positionFromTopLeft(padding, 0.26f);
activity.color = Color.grey;
ok = atlas.addSprite("ok.png", 0, 0);
ok.positionFromTopLeft(padding, 0.29f);
ok.color = Color.grey;
error = atlas.addSprite("error.png", 0, 0);
error.positionFromTopLeft(padding, 0.32f);
error.color = Color.grey;
#if UNITY_ANDROID && !UNITY_EDITOR
AndroidJNI.AttachCurrentThread();
AndroidJNIHelper.debug = false;
#endif
SocketHandler.SharedConnection.OnConnectEvent += OnConnected;
SocketHandler.SharedConnection.OnJSONEvent += OnJSONEvent;
SocketHandler.SharedConnection.OnStringEvent += OnStringEvent;
SocketHandler.SharedConnection.OnConnectionFailedEvent += OnConnectionFailedEvent;
SocketHandler.SharedConnection.OnReconnectEvent += OnReconnectEvent;
SocketHandler.SharedConnection.OnErrorEvent += OnErrorEvent;
SocketHandler.SharedConnection.OnDisconnectEvent += OnDisconnectEvent;
}
示例3: CreateGUI
private void CreateGUI()
{
UIToolkit ui = GameObject.Find("UIToolkit").GetComponent<UIToolkit>();
UIButton uiBackground = UIButton.create(ui, "Marge.png", "Marge.png", 0, 0);
uiBackground.color = new Color(0f, 0f, 0f, 0f);
uiBackground.setSize(Screen.width, Screen.height);
uiBackground.onTouchUpInside += uiBackground_onTouchUpInside;
uiBackground.zIndex = 10;
float buttonSize = Screen.width * 0.06f;
btnMargeArrow = UIButton.create(ui, "MargeArrow.png", "MargeArrow.png", 0, 0);
btnMargeArrow.setSize(buttonSize, buttonSize);
btnMargeArrow.positionFromTopLeft(0f, 0.01f);
btnMargeArrow.onTouchUpInside += btnMargeArrow_onTouchUpInside;
btnMargeArrow.zIndex = -1;
spriteMarge = ui.addSprite("Marge.png", 0, 0, -1);
spriteMarge.setSize(0.01f * Screen.width, 1 * Screen.height);
spriteMarge.positionFromTopLeft(0f, 0f);
spriteMarge.zIndex = -1;
//--- Conteneur
//var scrollable = new UIScrollableVerticalLayout(10);
//scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
//scrollable.position = new Vector3(Screen.width * 0.05f, -Screen.height * 0.1f, 0);
//var width = UI.scaleFactor * 150;
//scrollable.setSize(width, Screen.height * 0.8f);
//---
//UIGridLayout grid = new UIGridLayout(4, map.Layers.Count, 0);
//grid.edgeInsets = new UIEdgeInsets(0);
//grid.alignMode = UIAbstractContainer.UIContainerAlignMode.Left;
//grid.layoutType = UIAbstractContainer.UILayoutType.AbsoluteLayout
int i = 0;
foreach (Layer layer in map.Layers)
{
UIHorizontalLayout hLayout = new UIHorizontalLayout(0);
hLayout.zIndex = -2f;
listHLayout.Add(hLayout);
//int posY = 10 + i * 20;
//int margeX = 10;
//int deltaX = 10;
//int spaceX = 5;
//UIText text = new UIText(textManager, "prototype", "prototype.png");
UIButton btnBrowse = UIButton.create(ui, "Browse.png", "Browse.png", 0, 0);
UIButton btnMute = UIButton.create(ui, "Mute.png", "Mute.png", 0, 0);
UIButton btnSolo = UIButton.create(ui, "Solo.png", "Solo.png", 0, 0);
UIButton btnQuarter = UIButton.create(ui, "Quarter.png", "Quarter.png", 0, 0);
UIButton btnHalf = UIButton.create(ui, "Half.png", "Half.png", 0, 0);
UIButton btnNormal = UIButton.create(ui, "Normal.png", "Double.png", 0, 0);
UIButton btnDouble = UIButton.create(ui, "Double.png", "Double.png", 0, 0);
UIButton btnFourth = UIButton.create(ui, "Fourth.png", "Fourth.png", 0, 0);
btnBrowse.setSize(buttonSize, buttonSize);
btnMute.setSize(buttonSize, buttonSize);
btnSolo.setSize(buttonSize, buttonSize);
btnQuarter.setSize(buttonSize, buttonSize);
btnHalf.setSize(buttonSize, buttonSize);
btnNormal.setSize(buttonSize, buttonSize);
btnDouble.setSize(buttonSize, buttonSize);
btnFourth.setSize(buttonSize, buttonSize);
float layerButton = -3f;
btnBrowse.zIndex = layerButton;
btnMute.zIndex = layerButton;
btnSolo.zIndex = layerButton;
btnQuarter.zIndex = layerButton;
btnHalf.zIndex = layerButton;
btnNormal.zIndex = layerButton;
btnDouble.zIndex = layerButton;
btnFourth.zIndex = layerButton;
hLayout.addChild(btnBrowse, btnMute, btnSolo, btnQuarter, btnHalf, btnNormal, btnDouble, btnFourth);
hLayout.positionFromTopLeft(i * 0.1f, -0.5f);
i++;
}
}