コード例 #1
0
    /// <summary> Adds an order to the list of spawning things </summary>
    /// <param name="inst"> The instance to spawn </param>
    public void Add(SpawnInst inst)
    {
        float size_d = child_template.rect.height;

        var rectT = Instantiate(child_template.gameObject).GetComponent <RectTransform>();

        rectT.SetParent(transform);

        Parent.total.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Parent.total.rect.height + d_height);
        own_transform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, own_transform.rect.height + d_height);
        Parent.total.position  -= new Vector3(0, d_height / 2);
        own_transform.position -= new Vector3(0, d_height / 2);
        if (Parent.after != null)
        {
            Parent.after.Translate(new Vector3(0, -d_height));
        }

        rectT.transform.position = own_transform.position + new Vector3(20, own_transform.rect.yMin + d_height - 10);

        rectT.GetComponentInChildren <Button>().onClick.AddListener(Remove);
        rectT.GetComponentInChildren <Text>().text = inst.name;

        for (int i = Parent.commands.IndexOf(this) + 1; i < Parent.commands.Count; i++)
        {
            Parent.commands [i].Obj.transform.Translate(0, -d_height, 0);
        }

        containing.Add(new SpawnField()
        {
            inst = inst, transform = rectT
        });
    }
コード例 #2
0
 /// <summary> Should be called, when the dropdown selector is changed </summary>
 public void UpdateInp()
 {
     curr_inst = spawn_arr [type_choser.value];
 }