Пример #1
0
    private void addToggleDevice(SensorDevice device)
    {
        //calculated height of scroll container
        count++;
        scrollHeight = (height + 1.5f) * count;

        containerTransform.offsetMin = new Vector2(4.0f, -scrollHeight);
        containerTransform.offsetMax = new Vector2(-5.0f, 0);

        //create new entry
        GameObject newToggle = Instantiate(Resources.Load("Prefabs/Toggle_Device")) as GameObject;

        newToggle.name = device.ID;
        newToggle.transform.SetParent(deviceScroll.transform, false);

        displayedDevices.Add(device.ID, newToggle);

        RectTransform newRect = newToggle.GetComponent <RectTransform>();

        x = containerTransform.anchorMax.x;
        y = scrollHeight - 1.5f;

        newRect.offsetMax = new Vector2(x, y);

        x = containerTransform.anchorMin.x;
        y = scrollHeight - height;

        newRect.offsetMin = new Vector2(x, y);

        newToggle.GetComponentInChildren <Text>().text = device.ToString();
    }
Пример #2
0
 private void updateToggleDevice(SensorDevice device)
 {
     displayedDevices[device.ID].GetComponentInChildren <Text>().text = device.ToString();
 }