当前位置:网站首页>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()
{
}
}
边栏推荐
- 好用的shell快捷键
- Deep analysis - dynamic memory management
- 使用Unity做一个艺术字系统
- 【独立站建设】跨境电商出海开网店,首选这个网站建设!
- Hash table questions (Part 2)
- Okaleido ecological core equity Oka, all in fusion mining mode
- Word/excel has a fixed table size. When filling in the content, the table does not change with the cell content
- pinia的持久化存储,pinia使用插件进行持久化存储。
- [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...)
- The external symbol parsed by the method "public: virtual _ucdecl nvinfer1:: yololayerplugin:: ~yololayerplugin (void)" "public: virtual
猜你喜欢

Database leader Wang Shan: strive for innovation and carefully Polish high-quality database products

BSN IPFs (interstellar file system) private network introduction, functions, architecture and characteristics, access instructions

使用kubesphere图形界面dashboard开启devops功能

Convolution neural network -- a detailed introduction to convolution of 24 bit color images

Final review of management information system

The difference between ArrayList and LinkedList

JS three methods of traversing arrays: map, foreach, filter

Practice of microservice in solving Library Download business problems

结构型模式-外观(Facade)模式

Prometheus node exporter common monitoring indicators
随机推荐
结构型模式-装饰者模式
PX4模块设计之十二:High Resolution Timer设计
[untitled]
EVT interface definition file of spicy
微信小程序轮播图
Hash table questions (Part 2)
People don't talk much, engineers don't talk much
深度剖析 —— 动态内存管理
shel自动设置目录权限
从零开始C语言精讲篇4:数组
[small sample segmentation] msanet: multi similarity and attention guidance for boosting few shot segmentation
Introduction to regular expressions of shell, general matching, special characters: ^, $,., * Character range (brackets): [], special characters: \, matching mobile phone number
BSN IPFs (interstellar file system) private network introduction, functions, architecture and characteristics, access instructions
Remember the major performance problems caused by a TCP packet loss
JS three methods of traversing arrays: map, foreach, filter
P1438 boring sequence line segment tree + difference
项目参数做成可配置项,@ConfigurationProperties注解的使用
地平线 旭日X3 PI (四) 板上运行(未写完)
微服务的feign调用header头被丢弃两种解决方案(附源码)
C get UUID