当前位置: 首页 > news >正文

个人身份调查网站广东网站建设电话

个人身份调查网站,广东网站建设电话,公司vi设计内容,官网争锋注释 简单的随机生成UI且不发生重叠&#xff0c;可以修改算法进行更深入的探索 using System.Collections; using System.Collections.Generic; using UnityEngine;public class CellInfo {/// <summary>/// 物体位置/// </summary>public Vector2 pos;/// <s…

注释

简单的随机生成UI且不发生重叠,可以修改算法进行更深入的探索

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class CellInfo
{/// <summary>/// 物体位置/// </summary>public Vector2 pos;/// <summary>/// 物体宽/// </summary>public float width;/// <summary>/// 物体高/// </summary>public float height;
}/// <summary>
/// 屏幕随机生成文字并不叠加
/// </summary>public class TextTest : MonoBehaviour
{/// <summary>/// 外面的父级/// </summary>public RectTransform parent;/// <summary>/// 想要显示的子物体集合/// </summary>[Header("想要显示的子物体集合")]public List<GameObject> cells = new List<GameObject>();/// <summary>/// 已经存在的子物体信息/// </summary>private List<CellInfo> hadCells = new List<CellInfo>();/// <summary>/// 最大尝试的次数/// </summary>[Header("最大尝试的次数")]public int maxIndex;private void Update(){if (Input.GetKeyDown(KeyCode.Space)){StartCoroutine(CreateGameObject());}}/// <summary>/// 生成图片/// </summary>/// <returns></returns>public IEnumerator CreateGameObject(){int i = 0;while (i < cells.Count){float ItmeWidth = cells[i].GetComponent<RectTransform>().rect.width / 2;float ItmeHeigh = cells[i].GetComponent<RectTransform>().rect.height / 2;Vector2 cellPos = new Vector2(Random.Range(ItmeWidth, parent.rect.width - ItmeWidth),Random.Range(ItmeHeigh, parent.rect.height - ItmeHeigh));//尝试更新新坐标的次数int index = 0;while (index < maxIndex){if (i == 0 || (i != 0 && TwoPointDistance2D2(cellPos, ItmeWidth, ItmeHeigh))){CellInfo cellinfo = new CellInfo();cellinfo.pos = cellPos;cellinfo.width = ItmeWidth;cellinfo.height = ItmeHeigh;hadCells.Add(cellinfo);GameObject obj = Instantiate<GameObject>(cells[i], parent);obj.GetComponent<RectTransform>().position = cellPos;break;}index++;}i++;yield return null;}}/// <summary>/// 进行距离比较/// </summary>/// <param name="p1"></param>/// <param name="p2"></param>/// <returns></returns>private bool TwoPointDistance2D2(Vector2 currentPos, float w, float h){float x1 = currentPos.x - w;float x2 = currentPos.x + w;float y1 = currentPos.y - h;float y2 = currentPos.y + h;for (int i = 0; i < hadCells.Count; i++){float x11 = hadCells[i].pos.x - hadCells[i].width;float x22 = hadCells[i].pos.x + hadCells[i].width;float y11 = hadCells[i].pos.y - hadCells[i].height;float y22 = hadCells[i].pos.y + hadCells[i].height;if ((x2 < x11 || x1 > x22) && (y1 > y22 || y2 < y11)){continue;}else{return false;}}return true;}
}

http://www.yayakq.cn/news/16212/

相关文章:

  • 浙江省建设注册管理中心网站首页平面设计素材图库
  • 绍兴网站关键词优化WordPress mk主题
  • 深圳市网站建设做网站大地seo视频
  • 北京网站seo收费标准WordPress小工具可以做什么
  • 营销型网站有哪些app智能产品设计案例
  • 高校网站建设规范amp 网站开发
  • 上海一 网站建设公司网页制作培训班前景
  • 知名企业愿景网络优化的内容包括哪些方面
  • 苏州退工在哪个网站做企业服务公司起名
  • 网站怎么搭建公司变更通知
  • 潍坊营销型网站建设wordpress企业模板免费
  • 企业网站优化内容wordpress设置jetpack失败
  • 网站的定位与功能百度竞价推广账户
  • 网站换域名有没有影响吗自己制作微信小程序
  • 企业网站包含的内容wordpress上传主题直接使用
  • 网站建设论文要求黄冈网站推广策略
  • linux网站建设技术指南 百度网盘佛山优化网站排名收费
  • 百度下载appseo关键词优化推广报价表
  • 手机网站调用分享网络哪里能接活做网站
  • 做钻石的网站品牌营销名词解释
  • 自己公司内网网站和外网怎么做同步创建网站的目的是什么
  • 校园网站建设毕业设计网站建设 淄博
  • 郑州做网站服务器wordpress dux
  • 亚马逊店铺网站建设费用工信部网站备案登陆
  • 汕头网站专业制作建筑企业设计公司
  • win7如何做网站有做兼职赚钱的网站吗
  • 湖北网站建设优化emlog与wordpress
  • 重庆网站制作公司哪家好策划公司活动方案
  • 网站备案信息抽查陕西省建设执业资格注册中心网站
  • 做网站的那家公司好长沙短视频制作公司