❶ unity 怎么统一修改texture type
要修改一下图片的 导入类型。点击要修改的图片,在inspector面板中texture type修改成sprite就好了,如图所示这样。
❷ unity中怎么用描点法,画出一条曲线图,在ui上显示
可以自己写一个Shader
Shader "Custom/WireFrame"
{
Properties
{
_LineColor ("Line Color", Color) = (1,1,1,1)
_GridColor ("Grid Color", Color) = (1,1,1,0)
_LineWidth ("Line Width", float) = 0.2
}
SubShader
{
Pass
{
//Tags { "RenderType" = "Transparent" }
// Blend SrcAlpha OneMinusSrcAlpha//这句可以注释掉,能够避免线框太粗出现的模糊效果。
//AlphaTest Greater 0.5
//Cull Off//这句是后加的,取消遮挡消隐,体现出透明
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform float4 _LineColor;
uniform float4 _GridColor;
uniform float _LineWidth;
// vertex input: position, uv1, uv2
struct appdata
{
float4 vertex : POSITION;
float4 texcoord1 : TEXCOORD0;
float4 color : COLOR;
};
struct v2f
{
float4 pos : POSITION;
float4 texcoord1 : TEXCOORD0;
float4 color : COLOR;
};
v2f vert (appdata v)
{
v2f o;
o.pos = mul( UNITY_MATRIX_MVP, v.vertex);
o.texcoord1 = v.texcoord1;
o.color = v.color;
return o;
}
fixed4 frag(v2f i) : COLOR
{
fixed4 answer;
float lx = step(_LineWidth, i.texcoord1.x);
float ly = step(_LineWidth, i.texcoord1.y);
float hx = step(i.texcoord1.x, 1.0 - _LineWidth);
float hy = step(i.texcoord1.y, 1.0 - _LineWidth);
answer = lerp(_LineColor, _GridColor, lx*ly*hx*hy);
return answer;
}
ENDCG
}
}
Fallback "Vertex Colored", 1
}
❸ unity怎么设置物体锚点。
你可以给它添加一个空物体,作为它的子物体,也当成是锚点,然后用Transform.RotateAround();
❹ unity不规则序列帧如何对位
以下是三种方法:
第一个是重画序列帧,每一帧留出固定大小的空间。
第二个是在切割的时候手动去调每一帧的锚点。
第三个就是在动画编辑器里头手动调每一帧的位置。
缺点:第二和第三都特别繁琐,第一个的话图生成得特别大。
❺ unity5.0 ugui怎么以指定的物体的坐标作为锚点
//C#
public RectTransform target; //指定物件的RectTransform(锚点)
public Vector2 offset; //与锚点之间的距离
void Update(){
GetComponent<RectTransform>().anchoredPosition = target.anchoredPosition + offset;
}
❻ unity导出后图片大小改变
unity中直接导入高清图,通过max size来调节图片尺寸。
unity导出后图片不变的方法:
1、将图片扩展名改为.bytes,unity会将这个文件认为是文本文件,加载的时候按设置之后,在打包为AssetBundle的时候就会是原图尺寸。设置之后,在打包AssetBundle的时候就会是原图尺寸。
❼ u3d怎么调整ugui里的相对位置,使之和其他物体的相对位置不变
你好 我给你说一个方法 很简单 不用写代码:
把你画布里面Canvas Scaler属性的UI Scale Mode 设置为:Scale with Screen Size
在多出来的的两个输入框里输入你的屏幕分辨率
Screen Match Mode设置为:Match Width Or Height;下面的Match 设置为1(意思就是按高去匹配分辨率)
再把你UI的锚点设置到最中间就可以了;
亲测有效,你可以试一下。我不知道现在说还有没有用,也不知道你问题解决了没有,反正知道了以后再碰见就知道怎么办了,共勉吧。
❽ 改变锚点双向控制应该怎么做
模型软件中
模型-模型层次-轴调整改变到想要的位置,然后输出想要的模型格式
unity
创建空物体作为父物体,坐标(0,0,0),新建cube作为子物体(0.5,0.5,0.5),那么轴心如图示,就可以整体调用了。
代码设置
/// <summary>
/// 重置模型中心点
/// </summary>
[MenuItem("Tool/ResetCenterPosition")]
public static void ResetCenterPosition()
{
Transform transform = Selection.activeTransform;
Bounds bounds = new Bounds(Vector3.zero, Vector3.zero);
Vector3 center = Vector3.zero;
//获取物体Bound
foreach (var item in transform.GetComponentsInChildren<MeshRenderer>())
{
bounds.Encapsulate(item.bounds);
}
center = bounds.center;
//新建空物体,将原来中心点有问题的物体放置到该物体下作为子物体
GameObject obj = new GameObject();
obj.name = transform.name;
obj.transform.position = center;
obj.transform.rotation = Quaternion.identity;
//获取原物体在模型中的路径
string selectedObjPath = "";
Transform currentSelectTransform = transform;
while (currentSelectTransform.parent != null)
{
selectedObjPath = currentSelectTransform.parent.name + "/" + selected