Пример #1
0
    public override void UndoChange()
    {
        GUICircuitComponent component = null;

        foreach (GameObject obj in UnityEngine.Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (obj.tag.Equals("ActiveItem"))       // bacha lebo pri vytvarani noveho mu musim tiez dat tag active item
            {
                component = obj.GetComponent <GUICircuitComponent>();
                if (component.GetId() == objId)
                {
                    break;
                }
            }
        }

        if (component == null)
        {
            Debug.Log("There is something wrong with Undo/Redo");
        }
        else
        {
            component.SetAllProperties(properties);
        }
    }
Пример #2
0
    void GetObjectsFromScene()
    {
        List <GUICircuitComponent> sceneItems = new List <GUICircuitComponent>();

        foreach (GameObject obj in UnityEngine.Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (obj.tag.Equals("ActiveItem"))
            {
                //obj.GetComponent<GUICircuitComponent>().SetSimulationProp(sim);
                //_sceneItems.Push(obj.GetComponent<GUICircuitComponent>());
                sceneItems.Add(obj.GetComponent <GUICircuitComponent>());
            }
        }

        while (sceneItems.Count > 0)
        {
            DFS(sceneItems[0]);
            GUICircuitComponent[] newList = new GUICircuitComponent[traveledNodes.Count];

            traveledNodes.CopyTo(newList);
            _listOfNetworks.Add(newList);

            for (int i = 0; i < sceneItems.Count; i++)
            {
                if (traveledNodes.Contains(sceneItems[i]))
                {
                    sceneItems.RemoveAt(i);
                    i--;
                }
            }
            traveledNodes.Clear();
        }
    }
Пример #3
0
    public void Initialize(GUICircuitComponent component)
    {
        if (ConnectedConnectors == null)
        {
            ConnectedConnectors = new List <Connector>(20);
        }

        Component = component;
    }
Пример #4
0
    // If we let go of the left mouse button, end selection
    public void OnPointerUp(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Left)
        {
            return;
        }

        //select every item in selection bounds
        foreach (GameObject selectableObject in GameObject.FindGameObjectsWithTag("ActiveItem"))
        {
            if (IsWithinSelectionBounds(selectableObject.gameObject))
            {
                SelectObject.SelectedObjects.Add(selectableObject);
                selectableObject.GetComponent <SelectObject>().SelectionBox.GetComponent <SpriteRenderer>().enabled = true;
            }
        }

        foreach (GameObject selectableObject in GameObject.FindGameObjectsWithTag("ActiveNode"))
        {
            if (IsWithinSelectionBounds(selectableObject.gameObject))
            {
                SelectObject.SelectedObjects.Add(selectableObject);
                selectableObject.GetComponent <SelectObject>().SelectionBox.GetComponent <SpriteRenderer>().enabled = true;
            }
        }

        foreach (GameObject selectableObject in GameObject.FindGameObjectsWithTag("ActiveLine"))
        {
            if (IsWithinSelectionBounds(selectableObject.gameObject))
            {
                SelectObject.SelectedLines.Add(selectableObject);
                selectableObject.GetComponent <LineRenderer>().SetColors(Color.red, Color.red);
            }
        }

        //end of selecting
        _isSelecting = false;

        // Call the script from component that fills the Properties Window
        if (SelectObject.SelectedObjects.Count == 1)
        {
            GUICircuitComponent componentScript = SelectObject.SelectedObjects[0].GetComponent <GUICircuitComponent>();
            componentScript.GetProperties();
        }

        //enabling or disabling buttons in toolbar panel
        if (SelectObject.SelectedObjects.Count != 0)
        {
            _tbu.EnableToolbarButtons();
        }
        else
        {
            _tbu.DisableToolbarButtons();
        }
    }
Пример #5
0
    // Add a new item to the selection
    public static void AddItemToSelection(GameObject go)
    {
        SelectedObjects.Add(go);
        go.transform.FindChild("SelectionBox").GetComponent <SpriteRenderer>().enabled = true;

        // Call the script from component that fills the Properties Window
        if (SelectedObjects.Count == 1)
        {
            GUICircuitComponent componentScript = SelectedObjects[0].GetComponent <GUICircuitComponent>();
            componentScript.GetProperties();
        }
    }
Пример #6
0
    public override void UndoChange()
    {
        GUICircuitComponent component = null;

        foreach (GameObject obj in UnityEngine.Object.FindObjectsOfType(typeof(GameObject)))
        {
            if (obj.tag.Equals("ActiveItem"))       // bacha lebo pri vytvarani noveho mu musim tiez dat tag active item
            {
                component = obj.GetComponent <GUICircuitComponent>();

                if (component.GetId() == objId)
                {
                    break;
                }
            }
        }

        if (component == null)
        {
            Debug.Log("There is something wrong with Undo/Redo");
        }
        else
        {
            Vector3 changePos = new Vector3();
            Vector3 curPos    = component.gameObject.transform.position;

            changePos[0] = properties[1];
            changePos[1] = properties[2];
            //changePos[2] = curPos[2];

            component.gameObject.transform.position = component.gameObject.transform.position + changePos;

            if (properties.Count == 4)
            {
                component.gameObject.transform.Rotate(new Vector3(0, 0, properties[3]));
            }

            if (properties.Count == 5)
            {
                component.gameObject.transform.RotateAround(point, new Vector3(0, 0, 1), properties[3]);
            }
        }
    }
Пример #7
0
    public void OnPointerClick(PointerEventData eventData)
    {
        if (eventData.button == PointerEventData.InputButton.Middle || this.gameObject.tag == "ToolboxItem" || this.gameObject.tag == "Node" || this.gameObject.tag == "ToolboxItemActive" || this.gameObject.tag == "Untagged")
        {
            return;
        }

        // Deselect selected item first.
        if (!SelectedObjects.Contains(this.gameObject))
        {
            DeselectObject();
        }

        // Deselect line
        if (!SelectedObjects.Contains(this.gameObject))
        {
            GameObject line = GameObject.Find("Line(Clone)");
            if (line != null)
            {
                DeselectLine();
            }
        }

        // Select new object.
        if (!SelectedObjects.Contains(this.gameObject))
        {
            SelectedObjects.Add(this.gameObject);
            SelectionBox.GetComponent <SpriteRenderer>().enabled = true;
        }

        _tbu.EnableToolbarButtons();

        // Clear the Properties Window
        _script.Clear();

        // Call the script from component that fills the Properties Window
        if (SelectedObjects.Count == 1)
        {
            GUICircuitComponent componentScript = SelectedObjects[0].GetComponent <GUICircuitComponent>();
            componentScript.GetProperties();
        }
    }
Пример #8
0
    void DFS(GUICircuitComponent startNode)
    {
        if (!traveledNodes.Contains(startNode))
        {
            traveledNodes.Add(startNode);
            foreach (Connector c in startNode.Connectors[0].ConnectedConnectors)
            {
                if ((c != startNode.Connectors[0]) || (c != startNode.Connectors[1]))
                {
                    DFS(c.Component);
                }
            }

            foreach (Connector c in startNode.Connectors[1].ConnectedConnectors)
            {
                if ((c != startNode.Connectors[0]) || (c != startNode.Connectors[1]))
                {
                    DFS(c.Component);
                }
            }
        }
    }
Пример #9
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
 }
Пример #10
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
     Resistance = ((GUIResistor)old).Resistance;
 }
Пример #11
0
    public void DuplicateComponent()
    {
        List <GameObject> cloneComponents = new List <GameObject>();
        List <GameObject> cloneLines      = new List <GameObject>();

        // Get all game objects and find the top-left and bottom-right most components
        foreach (GameObject objectSelected in SelectObject.SelectedObjects)
        {
            if (objectSelected.tag.Equals("ActiveItem") || objectSelected.tag.Equals("ActiveNode"))
            {
                // Instantiate new copy GameObject
                GameObject copy =
                    (GameObject)Instantiate(objectSelected, objectSelected.transform.position, objectSelected.transform.rotation);
                copy.GetComponent <GUICircuitComponent>()
                .CopyValues(objectSelected.GetComponent <GUICircuitComponent>());
                copy.transform.FindChild("SelectionBox").GetComponent <SpriteRenderer>().enabled = false;

                // Clear connections of component's Plus and Minus connectors
                Connectable[] connectableScripts = copy.GetComponentsInChildren <Connectable>();
                foreach (Connectable connectableScript in connectableScripts)
                {
                    connectableScript.Connected.Clear();
                }

                // Add newly created clone to the list of clones
                cloneComponents.Add(copy);
            }
        }

        // Duplicate each line and interconnect clone objects
        foreach (GameObject line in SelectObject.SelectedLines)
        {
            GameObject duplicateLine = Instantiate(line);
            duplicateLine.GetComponent <Line>().KeepColiders();

            // Set the Begin of the duplicated line
            GameObject beginComponent = line.GetComponent <Line>().Begin.transform.parent.gameObject;
            // Get the index of Connector among component children
            int        beginChildConnectorIndex = -1;
            GameObject beginConnector           = line.GetComponent <Line>().Begin;
            for (int i = 0; i < beginComponent.transform.childCount; i++)
            {
                if (beginComponent.transform.GetChild(i).gameObject.GetInstanceID() == beginConnector.GetInstanceID())
                {
                    beginChildConnectorIndex = i;
                }
            }
            // Get index of component in the List of SelectedObjects
            int        beginComponentIndex = SelectObject.SelectedObjects.IndexOf(beginComponent);
            GameObject cloneBegin          = cloneComponents[beginComponentIndex];
            duplicateLine.GetComponent <Line>().Begin = cloneBegin.transform.GetChild(beginChildConnectorIndex).gameObject;

            // Set the End of the duplicated line
            GameObject endComponent = line.GetComponent <Line>().End.transform.parent.gameObject;
            // Get the index of Connector among component children
            int        endChildConnectorIndex = -1;
            GameObject endConnector           = line.GetComponent <Line>().End;
            for (int i = 0; i < endComponent.transform.childCount; i++)
            {
                if (endComponent.transform.GetChild(i).gameObject.GetInstanceID() == endConnector.GetInstanceID())
                {
                    endChildConnectorIndex = i;
                }
            }
            // Get index of component in the List of SelectedObjects
            int        endComponentIndex = SelectObject.SelectedObjects.IndexOf(endComponent);
            GameObject cloneEnd          = cloneComponents[endComponentIndex];
            duplicateLine.GetComponent <Line>().End = cloneEnd.transform.GetChild(endChildConnectorIndex).gameObject;

            // Add references of each other to both newly connected connectors of the duplicated objects
            duplicateLine.GetComponent <Line>().Begin.GetComponent <Connectable>().AddConnected(duplicateLine.GetComponent <Line>().End);
            duplicateLine.GetComponent <Line>().End.GetComponent <Connectable>().AddConnected(duplicateLine.GetComponent <Line>().Begin);

            duplicateLine.GetComponent <Line>().Begin.GetComponent <Connector>().ConnectedConnectors.Add(duplicateLine.GetComponent <Line>().End.GetComponent <Connector>());
            duplicateLine.GetComponent <Line>().End.GetComponent <Connector>().ConnectedConnectors.Add(duplicateLine.GetComponent <Line>().Begin.GetComponent <Connector>());

            // Add new line to the list of duplicated lines
            cloneLines.Add(duplicateLine);
        }

        SelectObject selectionComponent = GameObject.Find("Canvas").GetComponent <SelectObject>();

        selectionComponent.DeselectObject();
        selectionComponent.DeselectLine();
        SelectObject.AddItemsToSelection(cloneComponents);
        SelectObject.AddLinesToSelection(cloneLines);

        // Check for collisions - duplicated are placed on the same position as their originals so there MUST BE a collision
        GetComponent <Draggable>().Colision();

        UndoAction undoAction = new UndoAction();

        foreach (GameObject objectSelected in SelectObject.SelectedObjects)
        {
            if (objectSelected.tag.Equals("ActiveItem") || objectSelected.tag.Equals("ActiveNode"))
            {
                GUICircuitComponent component = objectSelected.GetComponent <GUICircuitComponent>();
                List <float>        prop      = new List <float>();
                prop.Add((float)1.0);
                prop.Add((float)component.GetId());
                prop.Add((float)objectSelected.gameObject.transform.GetChild(0).GetComponent <Connectable>().GetID());
                prop.Add((float)objectSelected.gameObject.transform.GetChild(1).GetComponent <Connectable>().GetID());

                CreateDeleteCompChange change = new CreateDeleteCompChange();
                change.SetPosition(objectSelected.transform.position);
                change.SetChange(prop);
                change.SetType(objectSelected.gameObject.GetComponent <GUICircuitComponent>().GetType());
                change.RememberConnectorsToFirst(objectSelected.gameObject.transform.GetChild(0).GetComponent <Connectable>().Connected);
                change.RememberConnectorsToSecond(objectSelected.gameObject.transform.GetChild(1).GetComponent <Connectable>().Connected);

                undoAction.AddChange(change);
            }
        }
        GUICircuitComponent.globalUndoList.AddUndo(undoAction);
    }
Пример #12
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
     Position = ((GUIPotentiometer)old).Position;
 }
Пример #13
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
     Capacitance = ((GUICapacitor)old).Capacitance;
 }
Пример #14
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
     Inductance    = ((GUIInductor)old).Inductance;
     IsTrapezoidal = ((GUIInductor)old).IsTrapezoidal;
 }
Пример #15
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
     MaxVoltage = ((GUIBattery)old).MaxVoltage;
 }
Пример #16
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public override void CopyValues(GUICircuitComponent old)
 {
     TurnedOff = ((GUIAnalogSwitch) old).TurnedOff;
 }
Пример #17
0
    public void DeleteSelected()
    {
        if (SelectObject.SelectedObjects.Count != 0)
        {
            UndoAction undoAction = new UndoAction();
            foreach (GameObject objectSelected in SelectObject.SelectedObjects)
            {
                GUICircuitComponent component = objectSelected.GetComponent <GUICircuitComponent>();
                List <float>        prop      = new List <float>();
                prop.Add((float)0.0);
                prop.Add((float)component.GetId());
                prop.Add((float)objectSelected.gameObject.transform.GetChild(0).GetComponent <Connectable>().GetID());
                prop.Add((float)objectSelected.gameObject.transform.GetChild(1).GetComponent <Connectable>().GetID());

                CreateDeleteCompChange change = new CreateDeleteCompChange();
                change.SetPosition(objectSelected.transform.position);
                change.SetChange(prop);
                change.SetType(objectSelected.gameObject.GetComponent <GUICircuitComponent>().GetType());
                change.RememberConnectorsToFirst(objectSelected.gameObject.transform.GetChild(0).GetComponent <Connectable>().Connected);
                change.RememberConnectorsToSecond(objectSelected.gameObject.transform.GetChild(1).GetComponent <Connectable>().Connected);

                undoAction.AddChange(change);

                if (objectSelected.tag.Equals("ActiveItem"))
                {
                    // List connected connectors with plusconnector
                    List <GameObject> connected1 =
                        objectSelected.transform.GetChild(0).GetComponent <Connectable>().Connected;

                    // List connected connectors with minusconnector
                    List <GameObject> connected2 =
                        objectSelected.transform.GetChild(1).GetComponent <Connectable>().Connected;

                    Connector con1 = objectSelected.transform.GetChild(0).GetComponent <Connector>();
                    Connector con2 = objectSelected.transform.GetChild(1).GetComponent <Connector>();

                    // First update list of connected connectors in connected component with this component
                    foreach (GameObject c in connected1)
                    {
                        c.gameObject.GetComponent <Connectable>().Connected.Remove(objectSelected.transform.GetChild(0).gameObject);
                        c.gameObject.GetComponent <Connector>().ConnectedConnectors.Remove(con1);
                    }

                    foreach (GameObject c in connected2)
                    {
                        c.gameObject.GetComponent <Connectable>().Connected.Remove(objectSelected.transform.GetChild(1).gameObject);
                        c.gameObject.GetComponent <Connector>().ConnectedConnectors.Remove(con2);
                    }

                    // For each lines in scene
                    GameObject[] lines = GameObject.FindGameObjectsWithTag("ActiveLine");

                    foreach (GameObject currentLine in lines)
                    {
                        // For every line connected to this component
                        if (objectSelected.transform.GetChild(0).gameObject ==
                            currentLine.GetComponent <Line>().Begin
                            ||
                            objectSelected.transform.GetChild(1).gameObject ==
                            currentLine.GetComponent <Line>().Begin
                            ||
                            objectSelected.transform.GetChild(0).gameObject ==
                            currentLine.GetComponent <Line>().End
                            ||
                            objectSelected.transform.GetChild(1).gameObject ==
                            currentLine.GetComponent <Line>().End)
                        {
                            Destroy(currentLine.gameObject);
                        }
                    }
                    Destroy(objectSelected);
                }
            }
            GUICircuitComponent.globalUndoList.AddUndo(undoAction);
            SelectObject.SelectedLines.Clear();
            GetComponent <SelectObject>().DeselectObject();
        }


        // Destroy selected line when delete key was pressed
        if (SelectObject.SelectedLines.Count != 0 && SelectObject.SelectedLines.Contains(this.gameObject))
        {
            UndoAction undoAction = new UndoAction();

            List <float> prop = new List <float>();
            prop.Add((float)0.0);
            prop.Add(this.gameObject.GetComponent <Line>().Begin.GetComponent <Connectable>().GetID());
            prop.Add(this.gameObject.GetComponent <Line>().End.GetComponent <Connectable>().GetID());

            CreateDeleteLineChange change = new CreateDeleteLineChange();
            change.SetChange(prop);
            undoAction.AddChange(change);
            GUICircuitComponent.globalUndoList.AddUndo(undoAction);

            // Delete connected connectors from lists of connectors
            this.gameObject.GetComponent <Line>().Begin.GetComponent <Connectable>().Connected.Remove(this.gameObject.GetComponent <Line>().End.gameObject);
            this.gameObject.GetComponent <Line>().End.GetComponent <Connectable>().Connected.Remove(this.gameObject.GetComponent <Line>().Begin.gameObject);

            this.gameObject.GetComponent <Line>().Begin.GetComponent <Connector>().ConnectedConnectors.Remove(this.gameObject.GetComponent <Line>().End.GetComponent <Connector>());
            this.gameObject.GetComponent <Line>().End.GetComponent <Connector>().ConnectedConnectors.Remove(this.gameObject.GetComponent <Line>().Begin.GetComponent <Connector>());

            Destroy(this.gameObject);
            SelectObject.SelectedLines.Remove(this.gameObject);
        }
    }
Пример #18
0
    public void OnBeginDrag(PointerEventData eventData)
    {
        if (eventData.button != PointerEventData.InputButton.Left)
        {
            return;
        }

        GameObject           propertiesContainer = GameObject.Find("PropertiesWindowContainer");
        EditObjectProperties script = propertiesContainer.GetComponent <EditObjectProperties>();

        // Deselect selected item first.
        if (SelectObject.SelectedObjects.Count != 0 && !SelectObject.SelectedObjects.Contains(this.gameObject))
        {
            //deselect item
            GameObject item = GameObject.Find("Canvas");
            item.GetComponent <SelectObject>().DeselectObject();

            // Deselect line
            GameObject line = GameObject.Find("Line(Clone)");
            if (line != null)
            {
                GameObject.Find("Canvas").GetComponent <SelectObject>().DeselectLine();
            }
        }
        else if (SelectObject.SelectedObjects.Count > 1 && SelectObject.SelectedObjects.Contains(this.gameObject))
        {
            // Setting starting positions for every selected elements
            _mousePos = Camera.main.ScreenToWorldPoint(eventData.position);
            foreach (GameObject objectSelected in SelectObject.SelectedObjects)
            {
                _itemPoss.Add(objectSelected.transform.position);
            }
        }
        //deselect line
        else
        {
            GameObject line = GameObject.Find("Line(Clone)");
            if (line != null)
            {
                GameObject.Find("Canvas").GetComponent <SelectObject>().DeselectLine();
            }
        }

        // Setting starting posiitons.
        _mousePos = Camera.main.ScreenToWorldPoint(eventData.position);
        _itemPos  = this.gameObject.transform.position;

        // ToolboxItemActive tagged GameObjects are used to generate new instances for the working panel.
        if (this.gameObject.tag == "Arrow" && this.gameObject.transform.parent.tag != "ToolboxItemActive")
        {
            _arrow    = this.gameObject;
            _arrowPos = new Vector2(this.gameObject.transform.parent.transform.position.x, _arrow.transform.position.y);
            _connectorPotentiometer    = this.gameObject.transform.parent.gameObject.transform.FindChild("PlusConnector").gameObject;
            _connectorPotentiometerPos = new Vector2(this.gameObject.transform.parent.transform.position.x, _connectorPotentiometer.transform.position.y);
        }
        else if ((this.gameObject.tag == "Arrow" && this.gameObject.transform.parent.tag == "ToolboxItemActive") ||
                 this.gameObject.tag == "ToolboxItemActive")
        {
            // Debug.Log(this.gameObject.transform.parent);
            GameObject item = this.gameObject;
            if (this.gameObject.transform.parent.tag == "ToolboxItemActive")
            {
                item = item.gameObject.transform.parent.gameObject;
            }

            tbitem = true;
            item.gameObject.tag = "ActiveItem";
            // Awake() function of every script is called when GameObject is instatiated. We need it to be instantiated as ActiveItem.
            _draggingItem       = Instantiate(item.gameObject);
            item.gameObject.tag = "ToolboxItemActive";
            _draggingItem.tag   = "ActiveItem";
            _draggingItem.layer = 8; //Name of 8th layer is ActiveItem
            _draggingItem.transform.localScale = new Vector3(1, 1, 0);
            _draggingItem.GetComponent <SpriteRenderer>().enabled          = true;
            _draggingItem.GetComponent <SpriteRenderer>().sortingLayerName = "ActiveItem";

            for (int i = 0; i < _draggingItem.transform.childCount; i++)
            {
                _draggingItem.transform.GetChild(i).GetComponent <SpriteRenderer>().sortingLayerName = "ActiveItem";
                _draggingItem.transform.GetChild(i).GetComponent <SpriteRenderer>().enabled          = true;
                _draggingItem.transform.GetChild(i).gameObject.layer = 8;
            }
            // Newly created component needs to be selected otherwise an error will occur
            SelectObject.AddItemToSelection(_draggingItem);

            UndoAction          undoAction = new UndoAction();
            GUICircuitComponent component  = _draggingItem.GetComponent <GUICircuitComponent>();
            List <float>        prop       = new List <float>();
            prop.Add((float)1.0);
            prop.Add((float)component.GetId());
            prop.Add((float)_draggingItem.gameObject.transform.GetChild(0).GetComponent <Connectable>().GetID());
            prop.Add((float)_draggingItem.gameObject.transform.GetChild(1).GetComponent <Connectable>().GetID());
            CreateDeleteCompChange change = new CreateDeleteCompChange();
            change.SetPosition(_draggingItem.transform.position);
            change.SetChange(prop);
            change.SetType(_draggingItem.gameObject.GetComponent <GUICircuitComponent>().GetType());
            change.RememberConnectorsToFirst(_draggingItem.gameObject.transform.GetChild(0).GetComponent <Connectable>().Connected);
            change.RememberConnectorsToSecond(_draggingItem.gameObject.transform.GetChild(1).GetComponent <Connectable>().Connected);
            undoAction.AddChange(change);
            GUICircuitComponent.globalUndoList.AddUndo(undoAction);
        }
        else if (this.gameObject.tag == "Node")
        {
            _draggingItem       = Instantiate(this.gameObject);
            _draggingItem.tag   = "ActiveNode";
            _draggingItem.layer = 8; //Name of 8th layer is ActiveItem
            _draggingItem.transform.localScale = new Vector3(1, 1, 0);
            _draggingItem.GetComponent <SpriteRenderer>().enabled          = true;
            _draggingItem.GetComponent <SpriteRenderer>().sortingLayerName = "ActiveItem";

            for (int i = 0; i < _draggingItem.transform.childCount; i++)
            {
                _draggingItem.transform.GetChild(i).GetComponent <SpriteRenderer>().sortingLayerName     = "ActiveItem";
                _draggingItem.transform.GetChild(i).GetComponent <SpriteRenderer>().transform.localScale = new Vector3(1, 1, 0);
                _draggingItem.transform.GetChild(i).GetComponent <SpriteRenderer>().enabled = true;
                _draggingItem.transform.GetChild(i).gameObject.layer = 8;
            }

            // Newly created component needs to be selected otherwise an error will occur
            SelectObject.AddItemToSelection(_draggingItem);
        }
        else if (SelectObject.SelectedObjects.Count == 0 || SelectObject.SelectedObjects.Count == 1 && SelectObject.SelectedObjects[0] == this.gameObject)
        {
            _draggingItem = this.gameObject;
            if (SelectObject.SelectedObjects.Count == 0)
            {
                // Select new object.
                SelectObject.SelectedObjects.Add(_draggingItem);
                _draggingItem.GetComponent <SelectObject>().SelectionBox.GetComponent <SpriteRenderer>().enabled = true;
            }

            // Clear the Properties Window
            script.Clear();

            // Call the script from component that fills the Properties Window
            GUICircuitComponent componentScript = _draggingItem.GetComponent <GUICircuitComponent>();
            componentScript.GetProperties();
        }

        _tbu.EnableToolbarButtons();
    }
Пример #19
0
 // Used for duplicating the components - old component is passes so the new one can copy needed values
 public virtual void CopyValues(GUICircuitComponent old)
 {
 }