/// <summary>
    /// Add Element Of Block Unit In Block Unit UI
    /// </summary>
    /// <param name="definitionContentOfBlock">Element content.</param>
    private DefinitionOfBlockEditorUnit AddDefinitionOfBlockEditorUnit(DefinitionContentOfBlock definitionContentOfBlock)
    {
        DefinitionOfBlockEditorUnit definitionOfBlockEditorUnit = BlockEditorManager.instnace.SpawnDefinitionOfBlockEditorUnit(definitionContentOfBlock);

        if (definitionOfBlockEditorUnit == null)
        {
            Debug.LogError("Cant Find Proper Type : " + definitionContentOfBlock.GetType().Name);
            return(null);
        }


        if (this.DefinitionOfBlockEditorUnitList == null)
        {
            this.DefinitionOfBlockEditorUnitList = new List <DefinitionOfBlockEditorUnit>();
        }

        if (this.DefinitionOfBlockEditorUnitList.Contains(definitionOfBlockEditorUnit) == false)
        {
            this.DefinitionOfBlockEditorUnitList.Add(definitionOfBlockEditorUnit);
        }

        definitionOfBlockEditorUnit.transform.SetParent(this.MainBlockTransform);
        definitionOfBlockEditorUnit.transform.localScale = Vector3.one;
        definitionOfBlockEditorUnit.transform.SetSiblingIndex(this.MainBlockTransform.childCount); // place elementOfBlockUnit To the last space of blockeditorunit

        definitionOfBlockEditorUnit.OwnerBlockEditorUnit = this;

        //

        if (definitionOfBlockEditorUnit is ParameterDefinitionOfBlockEditorUnit)
        {
            ParameterDefinitionOfBlockEditorUnit parameterDefinitionOfBlockEditorUnit = definitionOfBlockEditorUnit as ParameterDefinitionOfBlockEditorUnit;
            parameterDefinitionOfBlockEditorUnit.ParameterIndex = this.parameterIndex;
            this.parameterIndex++;
        }
        //

        definitionOfBlockEditorUnit.SetDefinitionContentOfBlock(definitionContentOfBlock);
        definitionOfBlockEditorUnit.OnSpawned();
        return(definitionOfBlockEditorUnit);
    }
示例#2
0
 public DefinitionOfBlockEditorUnit SpawnDefinitionOfBlockEditorUnit(DefinitionContentOfBlock definitionContentOfBlock)
 {
     if (definitionContentOfBlock is BooleanBlockInputDefinitionContentOfBlock)
     {
         return(PoolManager.SpawnObject(booleanBlockInputInBlockElement?.gameObject)?.GetComponent <DefinitionOfBlockEditorUnit>());
     }
     else if (definitionContentOfBlock is GlobalVariableSelectorDefinitionContentOfBlock)
     {
         return(PoolManager.SpawnObject(globalVariableSelectorDropDownInBlockElement?.gameObject)?.GetComponent <DefinitionOfBlockEditorUnit>());
     }
     else if (definitionContentOfBlock is ReporterBlockInputDefinitionContentOfBlock)
     {
         return(PoolManager.SpawnObject(reporterBlockInputInBlockElement?.gameObject)?.GetComponent <DefinitionOfBlockEditorUnit>());
     }
     else if (definitionContentOfBlock is TextDefinitionContentOfBlock)
     {
         return(PoolManager.SpawnObject(textInBlockElement?.gameObject)?.GetComponent <DefinitionOfBlockEditorUnit>());
     }
     else
     {
         Debug.LogError("Cant Find Proper Type : " + definitionContentOfBlock.GetType().Name);
         return(null);
     }
 }