protected override void Awake()
    {
        base.Awake();

        gameObject.tag     = BlockEditorUnitTag;
        _BlockMockupHelper = GetComponent <BlockMockupHelper>();
    }
    /// <summary>
    /// Creates the flow block mock up.
    /// </summary>
    /// <param name="flowBlockEditorUnit">Flow block editor unit.</param>
    /// <param name="siblingIndex">Sibling index.</param>
    public void CreateFlowBlockMockUp(FlowBlockEditorUnit flowBlockEditorUnit, int siblingIndex = 0)
    {
        if (flowBlockEditorUnit == null)
        {
            return;
        }

        BlockMockupHelper spawnedMockUp = PoolManager.SpawnObject(RobotSourceCodeEditorWindow.instance.BlockMockUpPrefab).GetComponent <BlockMockupHelper>();

        RobotSourceCodeEditorWindow.instance.AddToSpawnedBlockMockUp(spawnedMockUp);

        spawnedMockUp.CopyTargetBlock(flowBlockEditorUnit);

        Transform attachPointRectTransform = this.AttachPointRectTransform;


        spawnedMockUp._RectTransform.SetParent(attachPointRectTransform);
        spawnedMockUp._RectTransform.SetAsFirstSibling();
        spawnedMockUp._RectTransform.SetSiblingIndex(siblingIndex);

        spawnedMockUp._RectTransform.localScale = Vector3.one;
        //if copyBlockEditorUnit is FlowBlockEditorUnit
        //SetBlockMockUp nextblock of FlowBlockEditorUnit
        if (flowBlockEditorUnit.NextFlowBlockEditorUnit != null)
        {
            this.CreateFlowBlockMockUp(flowBlockEditorUnit.NextFlowBlockEditorUnit, siblingIndex + 1);
        }
    }
    public void AddToSpawnedBlockMockUp(BlockMockupHelper blockMockupHelper)
    {
        if (this.SpawnedBlockMockUp == null)
        {
            this.SpawnedBlockMockUp = new List <BlockMockupHelper>();
        }

        this.SpawnedBlockMockUp.Add(blockMockupHelper);
    }
Ejemplo n.º 4
0
    public void CopyTargetBlock(BlockEditorUnit blockEditorUnit)
    {
        if (blockEditorUnit == null)
        {
            return;
        }

        //transform.SetParent(blockEditorUnit.transform.parent);
        transform.SetAsFirstSibling();

        BlockMockupHelper targetBlockMockupHelper = blockEditorUnit._BlockMockupHelper;

        if (targetBlockMockupHelper != null)
        {
            for (int i = 0; i < this.images.Length; i++)
            {
                if (targetBlockMockupHelper.images.Length > i)
                {
                    if (targetBlockMockupHelper.images[i] == null)
                    {
                        continue;
                    }

                    this.images[i].gameObject.SetActive(targetBlockMockupHelper.images[i].gameObject.activeSelf);

                    if (this.images[i].gameObject.activeSelf == true)
                    {
                        this.images[i].sprite = targetBlockMockupHelper.images[i].sprite;
                        this.images[i].rectTransform.pivot            = targetBlockMockupHelper.images[i].rectTransform.pivot;
                        this.images[i].rectTransform.anchoredPosition = targetBlockMockupHelper.images[i].rectTransform.anchoredPosition;
                        this.images[i].rectTransform.sizeDelta        = targetBlockMockupHelper.images[i].rectTransform.sizeDelta;
                    }
                }
                else
                {
                    this.images[i].gameObject.SetActive(false);
                }
            }
        }
    }