protected virtual void OnDisable()
    {
        this._RobotSourceCode   = null; //for refrash editor window
        ActiveBlockEditorWindow = null;

        System.GC.Collect();
    }
示例#2
0
    /// <summary>
    /// Create New Block Instance with blockType And Create BlockEditorUnit
    /// </summary>
    /// <param name="blockType"></param>
    /// <param name="parent"></param>
    /// <returns></returns>
    public BlockEditorUnit CreateBlockEditorUnit(Type blockType, BlockEditorWindow blockEditorWindow, Transform parent = null)
    {
        if (blockType == null)
        {
            return(null);
        }

        return(this.CreateBlockEditorUnit(Block.CreatBlock(blockType), blockEditorWindow, parent));
    }
    /// <summary>
    /// Release(Destroy) BlockEditorUnit
    /// Disable This Object
    /// Clean ElementOfBlockUnitList
    /// Return back to
    /// </summary>
    public override void Release()
    {
        this.SaveUnitAnchoredPosition();
        // never touch element of targetBlock. Block is seperate from BlockEditorUnit
        // Removing BlockEditorUnit, Element Of BlockUnit shouldn't effect to Block instance
        this.ParentBlockEditorWindow = null;
        this.targetBlock             = null;

        ClearDefinitionOfBlockEditorUnit();

        this._BlockEditorUnitFlag = BlockEditorUnitFlag.None;

        base.Release();
    }
示例#4
0
 public static void RefreshBlockTextureArray()
 {
     try
     {
         //生成单个的预览贴图
         BlockEditorWindow.CreateBlockTextureArray
         (
             2048,
             BlockAnimFrameNumber + 1,
             new List <string>()
         {
             "Block" + BlockMaterialEnum.Normal.GetEnumName(), "Block" + BlockMaterialEnum.BothFace.GetEnumName(), "Block" + BlockMaterialEnum.BothFaceSwing.GetEnumName(), "Block" + BlockMaterialEnum.BothFaceSwingUniform.GetEnumName()
         }
         );
     }
     finally
     {
         EditorUI.GUIHideProgressBar();
     }
 }
    protected virtual void OnEnable()
    {
        if (ActiveBlockEditorWindow == null)
        {
            ActiveBlockEditorWindow = this;
        }
        else
        {
            if (ActiveBlockEditorWindow != this)
            {
                ActiveBlockEditorWindow.gameObject.SetActive(false);
                ActiveBlockEditorWindow = this;
            }
        }

        UiUtility.TargetCanvas = _Canvas;

#if UNITY_EDITOR
        tempSetRobotSourceCode();
#endif
    }
示例#6
0
    /// <summary>
    /// CreateBlockEditorUnit With Block Instance
    /// </summary>
    /// <param name="block"></param>
    /// <param name="parent"></param>
    /// <returns></returns>
    public BlockEditorUnit CreateBlockEditorUnit(Block block, BlockEditorWindow blockEditorWindow, Transform parent = null)
    {
        if (block == null)
        {
            Debug.LogError("block is null");
            return(null);
        }

        Type blockType = block.GetType();

        if (blockType.IsSubclassOf(typeof(Block)) == false)
        {
            Debug.LogError(blockType.Name + " is not subclass of Block");
            return(null);
        }

#if UNITY_EDITOR
        if (typeof(ILiteralBlock).IsAssignableFrom(blockType) == true)
        {
            Debug.LogError("Cang Make BlockEditrUnit Of LiteralBlock");
            return(null);
        }
#endif

        BlockEditorUnit blockEditorUnit = null;
        if (blockType.IsSubclassOf(typeof(BooleanBlock)))
        {
            blockEditorUnit = PoolManager.SpawnObject(booleanBlockEditorUnit?.gameObject)?.GetComponent <BlockEditorUnit>();
        }
        else if (blockType.IsSubclassOf(typeof(CapBlock)))
        {
            blockEditorUnit = PoolManager.SpawnObject(capBlockEditorUnit?.gameObject)?.GetComponent <BlockEditorUnit>();
        }
        else if (blockType.IsSubclassOf(typeof(CBlock)))
        {
            blockEditorUnit = PoolManager.SpawnObject(cBlockEditorUnit?.gameObject)?.GetComponent <BlockEditorUnit>();
        }
        else if (blockType.IsSubclassOf(typeof(HatBlock)))
        {
            blockEditorUnit = PoolManager.SpawnObject(hatBlockEditorUnit?.gameObject)?.GetComponent <BlockEditorUnit>();
        }
        else if (blockType.IsSubclassOf(typeof(ReporterBlock)))
        {
            blockEditorUnit = PoolManager.SpawnObject(reporterBlockEditorUnit?.gameObject)?.GetComponent <BlockEditorUnit>();
        }
        else if (blockType.IsSubclassOf(typeof(StackBlock)))
        {
            blockEditorUnit = PoolManager.SpawnObject(stackBlockEditorUnit?.gameObject)?.GetComponent <BlockEditorUnit>();
        }

        if (blockEditorUnit == null)
        {//Creating BlockEditorUnit Fail!!
            Debug.LogError("Cant Find Proper Type : " + blockType.Name);
        }
        else
        {//Creating BlockEditorUnit Success!!
            blockEditorUnit.gameObject.name = blockType.Name;

            if (parent != null)
            {
                blockEditorUnit.transform.SetParent(parent);
            }

            blockEditorUnit.transform.localScale = Vector3.one;

            blockEditorUnit.TargetBlock = block;

            blockEditorUnit.ParentBlockEditorWindow = blockEditorWindow;

            if (blockEditorUnit.IsRootBlock == true)
            {                                                                       //if rootblock
                if (blockEditorUnit.ReturnToSavedUnitAnchoredPosition() == false)
                {                                                                   //if fail return to SavedUnitAnchoredPosition
                    blockEditorUnit._RectTransform.anchoredPosition = Vector2.zero; // manually set
                }
            }

            blockEditorUnit.OnSpawned();
        }


        return(blockEditorUnit);
    }
示例#7
0
    /// <summary>
    /// Spawn Flow Block Recursivly
    /// Spawned Block create child block again,
    /// and spawned child block create child of block of that ..........
    /// </summary>
    /// <param name="flowBlock"></param>
    public FlowBlockEditorUnit SpawnFlowBlockEditorUnit(FlowBlock createdNewFlowBlock, FlowBlockEditorUnit parentBlockEditorUnit, BlockEditorWindow blockEditorWindow, Transform parent)
    {
        if (createdNewFlowBlock == null)
        {
            return(null);
        }

        FlowBlockEditorUnit blockEditorUnit = this.CreateBlockEditorUnit(createdNewFlowBlock, blockEditorWindow, parent) as FlowBlockEditorUnit;

        if (parentBlockEditorUnit != null)
        {
            FlowBlockEditorUnit.ConnectFlowBlockEditorUnit(parentBlockEditorUnit, blockEditorUnit);
        }

        if (createdNewFlowBlock.NextBlock != null)
        {
            this.SpawnFlowBlockEditorUnit(createdNewFlowBlock.NextBlock, blockEditorUnit, blockEditorWindow, parent);
        }



        return(blockEditorUnit);
    }
示例#8
0
 public static void RefreshBlockModelCommonRes()
 {
     //注: 如果是超过2048的图片 需要选用其他的压缩格式
     BlockEditorWindow.CreateBlockModel(2048, BlockEditorWindow.Path_FBX_BlockModelCommon, $"{BlockEditorWindow.Path_BlockTexturesMat}", "BlockCommon", BlockEditorWindow.Path_BlockMatCommon);
 }
示例#9
0
 public static void RefreshBlockModelCustomRes()
 {
     //注: 如果是超过2048的图片 需要选用其他的压缩格式
     BlockEditorWindow.CreateBlockModel(2048, BlockEditorWindow.Path_FBX_BlockModelCustom, $"{BlockEditorWindow.Path_BlockTexturesMat}", "BlockCustom", BlockEditorWindow.Path_BlockMatCustom, BlockAnimFrameNumber + 1);
     BlockEditorWindow.CreateBlockMeshData();
 }