Esempio n. 1
0
 //UI status
 void toggleStatus(ToggleObject t)
 {
     if (t.toggle.isOn)
     {
         t.imgOn.SetActive(true);
         t.imgOff.SetActive(false);
     }
     else
     {
         t.imgOn.SetActive(false);
         t.imgOff.SetActive(true);
     }
 }
Esempio n. 2
0
    private void ExecuteObjectScript(string [] tokens)
    {
        GameObject   o  = GameObject.Find(tokens[1]);
        ToggleObject tO = o.GetComponent <ToggleObject>();

        if (tokens[2] == "on")
        {
            tO.Toggle(true);
        }
        else if (tokens[2] == "off")
        {
            tO.Toggle(false);
        }
        else if (tokens[2] == "toggle")
        {
            tO.Toggle();
        }
    }
Esempio n. 3
0
    private void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
    {
        if (!(index < targets.Count && index >= 0))
        {
            return;
        }
        if (GUI.Button(new Rect(rect.x, rect.y + 2, 20, EditorGUIUtility.singleLineHeight), "X"))
        {
            targets.RemoveAt(index);
            CheckIfValid();
            Rename();
            return;
        }

        ToggleObject toggleObj = targets[index];
        Rect         myRect    = new Rect(rect.x + 22, rect.y + 2, rect.width - 42, EditorGUIUtility.singleLineHeight);

        EditorGUI.BeginChangeCheck();

        Object dummy;

        dummy = EditorGUI.ObjectField(myRect, toggleObj.Obj, typeof(GameObject), true);

        if (EditorGUI.EndChangeCheck())
        {
            if (dummy == null)
            {
                targets[index] = new ToggleObject();
            }
            else
            {
                if (((GameObject)dummy).scene.IsValid())
                {
                    targets[index] = new ToggleObject((GameObject)dummy);
                }
                else
                {
                    Debug.LogWarning("[QuickToggle] GameObject must be a scene object!");
                }
            }
            CheckIfValid();
        }
        float xCoord = rect.x + rect.width - 18;

        if (!toggleObj.valid)
        {
            EditorGUI.LabelField(new Rect(xCoord - 40, rect.y + 2, 25, EditorGUIUtility.singleLineHeight), warnIcon);
        }

        if (toggleObj.active)
        {
            if (GUI.Button(new Rect(xCoord, rect.y, 20, 18), greenLight, GUIStyle.none))
            {
                toggleObj.active = false;
                Rename();
            }
        }
        if (!toggleObj.active)
        {
            if (GUI.Button(new Rect(xCoord, rect.y, 20, 18), redLight, GUIStyle.none))
            {
                toggleObj.active = true;
                Rename();
            }
        }
    }
Esempio n. 4
0
    private void AddButtons(string Filter = "")
    {
        wallCount   = 0;
        doorCount   = 0;
        WindowCount = 0;
        furnCount   = 0;
        floorCount  = 0;

        for (int i = 0; i < itemList.Count; i++)
        {
            Item item = itemList[i];
            if (item.icon.name.Contains("Wall") && (Filter.Contains("Wall") || Filter == string.Empty))
            {
                GameObject newButton = buttonObjectPool.GetObject();
                newButton.transform.SetParent(contentPanel);
                newButton.name = "WaBtn" + wallCount.ToString();
                wallCount     += 1;

                ToggleObject sampleButton = newButton.GetComponent <ToggleObject>();
                sampleButton.enabled = disableButtons;
                sampleButton.Setup(item, this);
            }
            if (item.icon.name.Contains("Door") && (Filter.Contains("Door") || Filter == string.Empty))
            {
                GameObject newButton = buttonObjectPool.GetObject();
                newButton.transform.SetParent(contentPanel);
                newButton.name = "DoBtn" + doorCount.ToString();
                doorCount     += 1;

                ToggleObject sampleButton = newButton.GetComponent <ToggleObject>();
                sampleButton.enabled = disableButtons;
                sampleButton.Setup(item, this);
            }
            if (item.icon.name.Contains("Window") && (Filter.Contains("Window") || Filter == string.Empty))
            {
                GameObject newButton = buttonObjectPool.GetObject();
                newButton.transform.SetParent(contentPanel);
                newButton.name = "WiBtn" + WindowCount.ToString();
                WindowCount   += 1;

                ToggleObject sampleButton = newButton.GetComponent <ToggleObject>();
                sampleButton.enabled = disableButtons;
                sampleButton.Setup(item, this);
            }
            if (item.icon.name.Contains("Furniture") && (Filter.Contains("Furniture") || Filter == string.Empty))
            {
                GameObject newButton = buttonObjectPool.GetObject();
                newButton.transform.SetParent(contentPanel);
                newButton.name = "FuBtn" + furnCount.ToString();
                furnCount     += 1;

                ToggleObject sampleButton = newButton.GetComponent <ToggleObject>();
                sampleButton.enabled = disableButtons;
                sampleButton.Setup(item, this);
            }
            if (item.icon.name.Contains("Floor") && (Filter.Contains("Floor") || Filter == string.Empty))
            {
                GameObject newButton = buttonObjectPool.GetObject();
                newButton.transform.SetParent(contentPanel);
                newButton.name = "FlBtn" + floorCount.ToString();
                floorCount    += 1;

                ToggleObject sampleButton = newButton.GetComponent <ToggleObject>();
                sampleButton.enabled = disableButtons;
                sampleButton.Setup(item, this);
            }
        }
    }