unity5.0.1 破解 中的renderer没有material怎么办?

阅读:805回复:1
跪求大神回答,以下代码在IOS不起作用photo.renderer.material.shader=Shader.Find(&Unlit/Texture&)
发布于: 13:35
&& & & & photo.renderer.material.shader=Shader.Find(&Unlit/Texture&),以上这句代码在电脑是可以显示的,但是发布到ios上之后,这句代码就没有效果而且把图片都搞成红色的啦。请问以下为什么呢?有什么代码可以在ios顶替以上代码不?跪求大神回答!
鲜花1066朵
<span class="lou J_floor_copy" title="复制此楼地址"
data-hash="read_楼#
发布于: 10:03
也遇到同样的问题了,我是Resources.load解决的
不能改变世界,但我可以改变态度。
您需要登录后才可以回帖,&或者&
Powered byunity使用line renderer画线 - dzyi_的专栏
- 博客频道 - CSDN.NET
4876人阅读
任何一个无规则曲线它都是有若干个线段组成,及时是圆形它也是又若干个线段组成的,也就是说将若干个线段拼接起来就是我们须要的无规则曲线~那么在3D 的世界中我们须要知道 X Y Z 三个点来确定一条3D线段。
首先先使用Unity编辑器的方式来添加一条线~
Unity -& GameObject -& Create Empty 创建一个空的对象,我命名为line。然后点击 Component -& Miscellaneous -& Line Renderer 给line添加一个线渲染器的属性,Line Renderer是非常中的属性,下面我会详细的说明。
Create -& Material 创建一个材质,做来这个线段的贴图,下面我们看看Line Renderer的一些重要参数。
Cast Shadows: 是否投射阴影。
Receive Shadows: 是否接收阴影。
Materials :设置材质,这里可以设置多个材质, line就是上面我们创建的材质,这里我给line这个材质涂上了红颜色。
Positions:这个属性就比较重要了,它是专门设置线段在3D 世界中的点的坐标,size 设置点的数量 为3 那么将会有3个点,Element 0 &&Element 1&Element 2 & &这三个点将确定这条曲线分为两段,第一段是(0,0,1) 到 &(0,0,2) ,第二段是 (0,0,2) 到(0,0,4)。
Paramerters&
StartWidth :设置起点的宽度 &
EndWidth: &设置终点的宽度 ,这两项数&#20540;默认为1,但是现实起来很宽,所以一般都设置为0.几~&
Start Color: 设置起点颜色
Start Color: 设置终点颜色
Use World Space 使用世界坐标系
大家看看效果,清楚的可以看到曲线分为两部分,第一部分较短 第二部分较长。
怎么样? 绘制线的方法不难学吧?在已知线段位置的情况下我们可以使用上面的方法去设置这条线,但是如果线段的位置是在游戏过程中动态的产生就得在代码中去动态的去设置。
创建脚本Main.cs 绑定到摄像头上,运行游戏绘制线的话须要在Main中去拿到line这个对象的实例。这就是一个比较重要的知识点了。
一些重要的方法,在编辑器中编辑的一些东西,在代码中也可以做到。
LineRenderer.SetWidth(0.1,0.1) ; 设置线段起始点与结束点的宽度 (参数1 为起始点 参数2为结束点)
LineRenderer.SetColor(Color.black,Color.white);&设置线段起始点与结束点的颜色 (参数1 为起始点颜色 参数2为结束点颜色)
LineRenderer.SetVertexCount(5); 设置线段数量。
LineRenderer.useWorldSpace = 是否使用世界坐标系,和上面编辑器对应。
通过上面代码的设置,运行游戏,发现全新的一个三角形曲线赫然的映入我们的&#30524;帘,有了上面的方法我们就可以组合的绘制出各种各样的3D 游戏曲线了,这里MOMO使用的是颜色,大家也可以添加一个贴图~
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:39615次
排名:千里之外
评论:28条
(2)(2)(6)(2)Stack Overflow is a question and answer site for professional and enthusiast programmers. It&#39;s 100% free, no registration required.
Hi everybody I am having a problem with my game, the problem is based when I switch the materials so it can face the other direction (it is a 2d game). This affects the animation which is controlled by the renderer.material.mainTextureOffset but I have no idea why this is not working.
code in c#:
using UnityE
using System.C
public class character : MonoBehaviour {
public float forwardSpeed = 10.0f;
public Material newMaterialRefcs1;
public Material newMaterialRefcs2;
// Use this for initialization
void Start () {
//error is occurring here !!!!!!!! below Important. The 2 if statements below
// Update is called once per frame
void Update () {
if( Input.GetKey(KeyCode.D)){
renderer.material.mainTextureOffset = new Vector2(0.25f, 0);
transform.position += -transform.right * forwardSpeed * Time.deltaT
renderer.material = newMaterialRefcs1;
}if( Input.GetKey(KeyCode.A)){
renderer.material.mainTextureOffset = new Vector2(0.25f, 0);
transform.position += transform.right * forwardSpeed * Time.deltaT
renderer.material = newMaterialRefcs2;
50.1k1174167
I'm not sure exactly what your problem is but it sounds like you're trying to adjust one setting in the first script then add a new material in the second script. If that is the case then, when you assign the new material in the second script you are replacing the material completely meaning the renderer.material.mainTextureOffset.x that you set in the first gets overwritten.
Try keeping the offset in a separate variable that you can assign to the new texture when it is added in the second script.
Did you find this question interesting? Try our newsletter
Sign up for our newsletter and get our top new questions delivered to your inbox ().
Subscribed!
Success! Please click the link in the confirmation email to activate your subscription.
Try to use other shader. Diffuse, for example.
Also, check in inspector, is this value really changed. May You rewrite it in other script?
I have figured it out with some help from the unity forums took a while but here it is:
using UnityE
using System.C
public class character : MonoBehaviour {
public float forwardSpeed = 20.0f;
public float rot = 0f;public float jumpSpeed = 100;public float gravity = 30f;
public Material newMaterialRefcs1;
public Material newMaterialRefcs2;
void Start () {
public float scrollSpeed = 0.25F;
void Update () {
if( Input.GetKey(KeyCode.RightArrow)){
scrollSpeed += 0.25f;
transform.position += -transform.right * forwardSpeed * Time.deltaT
renderer.material = newMaterialRefcs1;
float offset = scrollS
renderer.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
}if( Input.GetKey(KeyCode.LeftArrow)){
scrollSpeed += 0.25f;
transform.position += transform.right * forwardSpeed * Time.deltaT
renderer.material = newMaterialRefcs2;
float offset = scrollS
renderer.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
Vector3 isgrounded = transform.TransformDirection(Vector3.up);
if( Input.GetKeyDown(KeyCode.Space)&& Physics.Raycast(transform.position, isgrounded, 6)){
transform.position -= transform.up * jumpSpeed * Time.deltaTime*2;
Physics.gravity = new Vector3(0, gravity, 0);
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z);
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabledunity3D中 material中tiling和offset属性解释
时间: 17:29:08
&&&& 阅读:166
&&&& 评论:
&&&& 收藏:0
标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&贴图有可能是多行多列的一些图案组成的。当我们需要一帧,一帧的播放时候。也就是帧序列动画,
我们就需要用到tiling和offset两个属性,
默认图片的左下角为坐标圆点即:(0,0)
tiling是图片的大小,offset是偏移量
来看看一些例子:
1 using UnityE
2 using System.C
4 public class animspite : MonoBehaviour
public int totolF//总帧数,即多少帧
public int//帧速度 即 1秒运行多少帧
public int rowN //几行
public int colN //几列
public bool isDes = false; //是否播放一次就销毁对象
// Use this for initialization
void Start()
//判断当前平台
#if UNITY_EDITOR
Debug.Log("Unity Editor");
#if UNITY_IPHONE
Debug.Log("Iphone");
#if UNITY_STANDALONE_OSX
Debug.Log("Stand Alone OSX");
#if UNITY_STANDALONE_WIN
Debug.Log("Stand Alone Windows");
// Update is called once per frame
void Update()
int index = (int)(Time.time * fbs);
index = index % totolF
float sizeX = 1.0f / colN
float sizeY = 1.0f / rowN
Vector2 size = new Vector2(sizeX, sizeY);
float uIndex = index % colN
float vIndex = index / colN
float offsetX = uIndex * size.x;
float offsetY = (1.0f - size.y) - (vIndex * size.y);
//offsetY = 1.0f * vIndex / rowN
Vector2 offset = new Vector2(offsetX, offsetY);
transform.renderer.material.mainTextureScale =
transform.renderer.material.mainTextureOffset =
if (isDes)
if (Time.time & 1)
Destroy(this.gameObject);
&标签:&&&&&&&&&&&&&&&&&&&&&&&&&&&
&&&& &&&&it168&& && && &&
版权所有 鲁ICP备号-4
打开技术之扣,分享程序人生!}

我要回帖

更多关于 unity5.0.1 破解 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信