c# - 为什么图像没有在统一中获得新的位置?
问题描述
这是一个示例图像。指向中心的箭头是我需要的位置。位置、旋转、缩放。
现在我制作了一个随机化单个数字(0...5)(位置)的脚本。然后是另一个随机数,从 0 到 11(元素)(取哪个位置)。
接下来,在这些位置,我已经添加了一个新元素。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Respawn : MonoBehaviour {
public Transform[] Points;
public Image[] Images;
int Count;
// Use this for initialization
void Start () {
Randomize ();
}
// Update is called once per frame
void Update () {
}
void Randomize() {
Count = Random.Range (0, 5);
for (int i = 0; i <= Count; i++) {
int Selected;
Selected = Random.Range (0, 11);
Selector (Selected);
}
}
void Selector(int id) {
Images [id].transform.position = Points [id].transform.position;
Images [id].transform.rotation = Points [id].transform.rotation;
Images [id].transform.localScale = new Vector3(0.1f,0.1f);
Instantiate (Images [id], Points [id], Points [id]);
Debug.Log ("Point - " + Points [id].transform.position);
Debug.Log ("Image - " + Images [id].transform.position);
Debug.Log ("\n");
}
}
它不起作用,但我想我只想添加图片并且已经禁用或启用它们
解决方案
推荐阅读
- python-3.x - 如何使我的服务器能够读取客户端发送的数据
- windows - 如何以用户身份运行 Jenkins 管道?
- c# - 如何使用 LINQ 将列表过滤成相同类型的新列表?
- google-apps-script - ArrayFormula 正在影响 getLastRow
- r - 闪亮的错误:未使用的参数(main = "Smear plot",de.tags = dgeChangedGenes())
- python - 仅使用顶级域映射网站
- android - 在 Firebase 的同一集合中更新多个文档中的字段值
- pandas - 连接多行并在特定列上求和
- python - Python 中的 .groupby 函数
- javascript - 什么是在 express js 上获取和发布