Beispiel #1
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Delete))
        {
            var controller = controllers[selectedIndex];
            FoveManager.DeleteProfile(controller.ProfileName);
            Destroy(controller.gameObject);
            controllers.RemoveAt(selectedIndex);
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            validateSelectedItem(false);
            ++selectedIndex;
        }
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            validateSelectedItem(false);
            --selectedIndex;
        }
        else if (Input.GetKeyDown(KeyCode.F2))
        {
            controllers[selectedIndex].EnterNameEditMode();
        }
        else if (Input.GetKeyDown(KeyCode.Insert))
        {
            var item = GameObject.Instantiate(profileItemPrefab);
            item.transform.SetParent(layout.transform, false);

            var controller = item.GetComponent <ProfileItemController>();
            controller.EnterNameEditMode();
            controllers.Add(controller);

            selectedIndex = controllers.Count - 1;
        }
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            validateSelectedItem(true);
        }

        if (controllers.Count == 0)
        {
            return;
        }

        // else if RENAME
        // else if CREATE
        selectedIndex = (selectedIndex + controllers.Count) % controllers.Count;

        string selectedProfile         = controllers[selectedIndex].ProfileName;
        string selectedProfileDataPath = "";

        var currProfile = FoveManager.GetCurrentProfile().value;

        if (!string.IsNullOrEmpty(selectedProfile))
        {
            selectedProfileDataPath = FoveManager.GetProfileDataPath(selectedProfile);
        }

        dataPathText.text = "Data Path: \"" + selectedProfileDataPath + "\"";

        for (int i = 0; i < controllers.Count; i++)
        {
            var controller = controllers[i];
            controller.isSelected = i == selectedIndex;
            controller.isCurrent  = controller.ProfileName == currProfile;
        }
    }