当前位置:网站首页>Use unity to build a WordArt system
Use unity to build a WordArt system
2022-07-27 04:35:00 【Geek style】
For familiarity CaptureScreen Method , Make a WordArt system .
First declare a public variable toward, In order to script in the book Cature_Use Call in , Then give another variable delays Assign a random value , So that the movement of each ball is more real 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Capture_Use_Sub : MonoBehaviour
{
// Where the object is moving
public Vector3 toward;
float delays;
void Start()
{
// Get a random value
delays = Random.Range(2.0f, 4.0f);
}
void Update()
{
// By changing the position of the object to achieve the effect of object motion
transform.position = Vector3.MoveTowards(transform.position, toward, delays);
}
}
Then create the main program 
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Capture_Use : MonoBehaviour
{
//td: Used to point to a screenshot
Texture2D td = null;
//txt_bg: Beijing pictures used to point to text input
// You can point to a solid color picture , You can also customize a solid color Beijing
// This program defines a solid color background
Texture2D txt_bg;
//txt_w and txt_h It is used to record the width and height of the text box
int txt_w, txt_h;
//my_save_path: Used to record the save path of the screenshot
string my_save_path = "";
//show_txt: Used to record input text
string show_txt = " Enter here ";
//myh_colors: Used to record the texture color of the text input box
Color[] colors;
// _w, _h; Used to record my_color Width and height
int _w, _h;
//step: Used to record the current state ,step share 4 States
//step=0 when , Is waiting state , Waiting for text to be entered in the text box
//step=1 when , Click “ determine ” After button , Generate screenshots and save
//step=2 when , Read the screenshot information
//step=3 when , It is the selective extraction of the screenshot information , And generate the Beirong you want to show
int step = 0;
//go: It's used to point to the object of spelling
public GameObject go;
//gos: To record everything go object
GameObject[] gos;
//gos_max Used to record gos Maximum number of
int gos_max;
//gos_cur Used to record gos Current quantity
int gos_cur = 0;
//is_show: It is used to record whether a point in the image matrix needs to show an object
bool[,] is_show;
void Start()
{
// Initialize the width and height of the text box
txt_w = 200;
txt_h = 80;
// Initialize the size of the intercept interval , Velle avoids boundary recognition errors , Its value should be a few pixels less than the width and height of the text box
_w = txt_w;
_h = txt_h;
_w -= 5;
_h -= 5;
// Customize txt_bg texture
txt_bg = new Texture2D(txt_w, txt_h);
Color[] tdc = new Color[txt_w * txt_h];
for (int i = 0; i < txt_w * txt_h; i++)
{
// The pixel colors used are the same
tdc[i] = Color.white;
}
txt_bg.SetPixels(0, 0, txt_w, txt_h, tdc);
is_show = new bool[_h, _w];
// initialization gos_max, Its value size is txt_w * txt_h One third
gos_max = _w * _h / 3;
// Instantiation gos, Make it randomly distributed _w, _h Within the range of
gos = new GameObject[gos_max];
for (int i = 0; i < gos_max; i++)
{
gos[i] = (GameObject)Instantiate(go, new Vector3(Random.value * _w, Random.value * _h, 10.0f), Quaternion.identity);
gos[i].GetComponent<Capture_Use_Sub>().toward = gos[i].transform.position;
}
// Save the screenshot of the accident interface
my_save_path = Application.persistentDataPath;
ScreenCapture.CaptureScreenshot(my_save_path + "/test02.png");
}
void Update()
{
}
}
边栏推荐
- Convolution neural network -- a detailed introduction to convolution of 24 bit color images
- Elastic certification test: 30 day FastPass Study Guide
- Nacos startup and login
- timestamp列使用varchar类型和使用date类型有什么区别?
- BSN IPFs (interstellar file system) private network introduction, functions, architecture and characteristics, access instructions
- Network knowledge corner | it only takes four steps to teach you to use SecureCRT to connect to ENSP. You must see the operation guide of common tools
- Brightcove任命Dan Freund为首席营收官
- els 方块显示原理
- STM32 serial port based on Hal library accepts interrupts and idle interrupts
- 2022杭电多校联赛第三场 题解
猜你喜欢

F - Pre-order and In-order(Atcoder 255)
![[final review of software engineering] knowledge points + detailed explanation of major problems (E-R diagram, data flow diagram, N-S box diagram, state diagram, activity diagram, use case diagram...)](/img/f4/70634556c4ae8fc3b087084e1e27b3.png)
[final review of software engineering] knowledge points + detailed explanation of major problems (E-R diagram, data flow diagram, N-S box diagram, state diagram, activity diagram, use case diagram...)

playwright网络爬虫实战案例分享

JS three methods of traversing arrays: map, foreach, filter
深度学习领域图像分割FCN(Fully Convolutional Networks for Semantic Segmentation)

Spark practice case (upgraded version)

好用的shell快捷键

Prometheus Node Exporter 常用监控指标

Brightcove appoints Dan Freund as chief revenue Officer

无有线网络下安装并配置debian
随机推荐
Yolov4网络详解
安全第四次课后练习
Scala immutable map, variable map, map conversion to other data types
[untitled]
Okaleido ecological core equity Oka, all in fusion mining mode
pinia的持久化存储,pinia使用插件进行持久化存储。
使用WebMvcConfigurer进行接口请求拦截进行中增强(附源码)
els 兼容性DC、传递图片到窗口
Standard C language 13
Anonymous named pipes, understanding and use of interprocess communication in shared memory
题目:有一个已经按升序排好序的数组。现输入一个数,要求按原来的规律将它插入数组中。
Ref Hook
从零开始C语言精讲篇4:数组
RSA asymmetric encryption and decryption signature verification tool
好用移动APP自动化测试框架哪里找?收藏这份清单就好了!
Effect Hook
playwright网络爬虫实战案例分享
Redis interview question (2022)
People don't talk much, engineers don't talk much
els 方块显示原理