亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

unity實(shí)現(xiàn)屏幕上寫(xiě)字效果

 更新時(shí)間:2019年07月16日 11:25:56   作者:人生若只如初見(jiàn)~~~  
這篇文章主要為大家詳細(xì)介紹了unity實(shí)現(xiàn)屏幕上寫(xiě)字效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了unity實(shí)現(xiàn)屏幕上寫(xiě)字效果的具體代碼,供大家參考,具體內(nèi)容如下

先建立一個(gè)RawImage,然后再在這個(gè)圖片上加個(gè)LineRenderer組件,再建個(gè)材質(zhì)球,把材質(zhì)球的Shader改成Particles/Additive,把材質(zhì)球拖給LineRenderer組件的Materials/Element 0(不拖也可以),最后再把代碼拖給空物體即可,代碼的Target是RawImage,下面的代碼

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class huaxian : MonoBehaviour 
{

private GameObject clone;
private LineRenderer line;
int i;

//帶有LineRender物體
public GameObject target;

void Start()
{
  Debug.Log("請(qǐng)開(kāi)始寫(xiě)字");
} 

// Update is called once per frame 
 void Update()
{
  if (Input.GetMouseButtonDown(0))
  {
    //實(shí)例化對(duì)象 
    clone = (GameObject)Instantiate(target, target.transform.position, Quaternion.identity);
    //獲得該物體上的LineRender組件 
    line = clone.GetComponent<LineRenderer>();
    //設(shè)置起始和結(jié)束的顏色 
    line.SetColors(Color.red, Color.blue);
    //設(shè)置起始和結(jié)束的寬度  
    line.SetWidth(0.2f, 0.1f);
    //計(jì)數(shù)  
    i = 0;
  }
   if (Input.GetMouseButton(0))
  {
    //每一幀檢測(cè),按下鼠標(biāo)的時(shí)間越長(zhǎng),計(jì)數(shù)越多 
    i++;
    //設(shè)置頂點(diǎn)數(shù) 
    line.SetVertexCount(i);
    //設(shè)置頂點(diǎn)位置(頂點(diǎn)的索引,將鼠標(biāo)點(diǎn)擊的屏幕坐標(biāo)轉(zhuǎn)換為世界坐標(biāo)) 
    line.SetPosition(i - 1, Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 15)));
  }
 }
 
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論