首页 > 解决方案 > 为什么图像没有在统一中获得新的位置?

问题描述

我创建了一个圆圈并添加了圆周对象。 在此处输入图像描述

这是一个示例图像。指向中心的箭头是我需要的位置。位置、旋转、缩放。

现在我制作了一个随机化单个数字(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");
}
}

它不起作用,但我想我只想添加图片并且已经禁用或启用它们

标签: c#unity3dposition

解决方案


推荐阅读