Relation关联,实质是FairyGUI提供的布局、适配的解决方案。特点是不仅可以针对父级容器设定相对位置关系,还可以设置相对于其他元件的相对位置关系。

导出资源

代码实现

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
/*
 * Author:W
 * 关联:布局、适配
 * 1.可以设置相对于“父级”的位置
 * 2.也可以设置其他元件的位置
 */
public class RelationTest : MonoBehaviour {

	private GComponent root;

	private GComponent frame;
	void Awake()
	{
		UIPackage.AddPackage("UI/Basics");
	}

	// Use this for initialization
	void Start () {
		root = this.GetComponent<UIPanel>().ui;

		frame = root.GetChild("n13").asCom;
		frame.AddRelation(root, RelationType.Bottom_Bottom);
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

运行结果如下

 

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐