uGUI:
Reference from : https://www.jianshu.com/p/04432f3cf664
RectTransform的作用用来计算UI的位置和大小,RectTransform继承于Transform,具有Transform的所有特征,通过RectTransform能够实现基本的布局和层次控制。
RectTransform当中专有名字:
--Pos X, Pos Y :Pivot与Anchor的距离
--Pivot :中轴,中心点
--Anchor :锚点
--Width&Height :宽与高,相对于锚点
--Left, Right, Top, Bottom :左右上下
中心点Pivot
按下T键选中某一个UI控件即可看到UI控件的中心点,中心点也叫中心轴,当鼠标拖动UI控件进行旋转的时候会围绕中心点旋转。
--中心点是矩形的一部分。
--0对应左下角,1对应右上角。
锚点Anchor:
如图所示,箭头所指即为锚点,锚点表示的是相对于父级矩形的子矩形区域。
如图所示,锚点为四边形,锚点有多种摆放方式,可以为矩形,点状或是为线状。
锚点移动范围仅限于父级视图当中.
锚点的四种摆放方式:
--锚点呈点状
--锚点与组件本身重合
--锚点跟父物体重合
--锚点呈线状
Panel :面板,功能相当于控制的容器,里面可以存放其他控件。
--作用: 使用Panel控件可以整体移动和处理一组控件。
--设计规范: 一个功能完备的UI界面往往会使用多个Panel控件。
示例: 将资源商店当中的所有分类放在单独一块Panel当中。
InputField创建出来如下图,InputField层级视图当中包含Placeholder与Text,
--Placeholder 用于显示占位符,即输入框没有输入文本时显示的文本,例如下图的“Enter text”;
--Text 用于显示输入的内容。
输入框Inputield的具体属性:
--Text :初始文本显示的内容
--Character Limit :字符数量限制。
--Content Type :文本类型。
--Line Type :文本单行显示还是多行。
--Caret Blink Rate :光标闪动频率。
--Caret Width :光标的宽度。
--Custom Caret Color :自定义光标的颜色。
--Selection Color :选中文本时的颜色。
--On Value Changed(String) :文本编辑时触发的事件。
--On End Edit(string) :结束编辑的时候触发的事件。
battleHub TreeView的使用:
1.add Canvas
2.add Treeview Prefab to the Canvas for the child of it.
3.添加subscribe and unsubscribe事件
4.Bind data items
//可以拖/拽切换父节点,也可以多选来切换,选择后,自动滚动,选中单个或多个后按del删除
UITable的使用:
1.右键UI/Table
2.在Table组件中,指定它的collection数据集
//注:collection需实现IEnumerable<>接囗
3.往下就有columns列会出现,可添加
Animator/AnimationClip
- 如果是只可读的文件,关键帧的骨骼信息不可删除,可复制为新的动画文件后,再手动删除关键帧信息
- 获取关键帧信息,保存为新的动画文件
- 可以使用Unity提供的接口**AnimationUtility**
- 复制控制器上所有的Clip
void OnPostprocessModel_CopyAni(GameObject g)
{
AnimationClip[] clips = AnimationUtility.GetAnimationClips(g);
foreach (AnimationClip clip in clips)
{
DuplicateAnimationClip(clip);
}
}
void DuplicateAnimationClip(AnimationClip sourceClip)
{
if (sourceClip != null)
{
string path = AssetDatabase.GetAssetPath(sourceClip);
path = Path.Combine(Path.GetDirectoryName(path), sourceClip.name) + ".anim";
string newPath = AssetDatabase.GenerateUniqueAssetPath(path);
AnimationClip newClip = new AnimationClip();
EditorUtility.CopySerialized(sourceClip, newClip);
AssetDatabase.CreateAsset(newClip, newPath);
}
}
Unity-Linux:
UNITY_SYSROOT_CACHE environment variable
sysroots
toolchain
Your best bet is to build the game without "headless" option then run the game with command line argument -batchmode (docs.unity3d.com/Manual/CommandLineArguments.html). I presume headless option will force the -nographics option on your builds
Server Build是不需要在服务器上使用显卡的; 且仅在Linux和Windows
Headless Mode which is useful if we want to run game servers without any graphics
检测Headless模式:Detect Headless Mode in Unity:
void Awake() {
if (IsHeadless()) {
print("headless mode detected");
StartServer();
}
}
bool IsHeadless() {
return SystemInfo.graphicsDeviceType == GraphicsDeviceType.Null;
}
启用 Alpha Clipping 选项,将 Threshold(阈值)设置为 0.5。阈值的作用是:如果 Alpha 通道中的某个像素对应的灰度值小于 0.5,那么 HDRP 就不会渲染这个像素;反之如果大于等于 0.5 则渲染此像素 作者:Unity官方 https://www.bilibili.com/read/cv12482083/ 出处:bilibili
HDRP和URP的区别:
1.使用了color templerature to set the lighting color(而不仅是diffuse或specular lighting),
2.可以控制inner angles and shapes of Spot Lights
3.支持color cookies和allow the use of real-time area lights
4.HDRP removed the Built-in Unity ‘Gamma Mode’ and uses the precise ‘Linear Mode’.
float4 gamma_correction(float4 source)
{
if (is_linear)
return float4(LinearToGammaSpace(source), LinearToGammaSpaceExact(source.a));
return source;
}