private void InitSourceCodeViewer() { if (this._RobotSourceCode == null) { return; } //Spawn Hat Blocks BlockEditorUnit initBlockEditorUnit = BlockEditorManager.instnace.SpawnFlowBlockEditorUnit(this._RobotSourceCode.InitBlock, null, this, SourceCodeViewerRectTransform); BlockEditorUnit loopedBlockEditorUnit = BlockEditorManager.instnace.SpawnFlowBlockEditorUnit(this._RobotSourceCode.LoopedBlock, null, this, SourceCodeViewerRectTransform); if (initBlockEditorUnit != null) { initBlockEditorUnit.BackupTransformInfo(); } if (loopedBlockEditorUnit != null) { loopedBlockEditorUnit.BackupTransformInfo(); } EventBlock[] eventBlocks = this._RobotSourceCode.StoredEventBlocks; if (eventBlocks != null) { foreach (var eventBlock in this._RobotSourceCode.StoredEventBlocks) { BlockEditorUnit blockEditorUnit = BlockEditorManager.instnace.SpawnFlowBlockEditorUnit(eventBlock, null, this, SourceCodeViewerRectTransform); loopedBlockEditorUnit.BackupTransformInfo(); } } // }
public override void Release() { // never touch element of targetBlock. Block is seperate from BlockEditorUnit // Removing BlockEditorUnit, Element Of BlockUnit don't effect to Block instance this.OwnerBlockEditorUnit = null; base.Release(); }
public void RemoveFromSpawnedBlockEditorUnitInSourceCode(BlockEditorUnit blockEditorUnit) { if (this.SpawnedBlockEditorUnitInSourceCode == null) { return; } this.SpawnedBlockEditorUnitInSourceCode.Remove(blockEditorUnit?.TargetBlock); }
/// <summary> /// Make This Flow Block EditorUnit RootBlock /// This block will not have previous block /// </summary> public void SetBlockHoverOnEditorWindow(BlockEditorUnit blockEditorUnit) { if (blockEditorUnit == null) { return; } blockEditorUnit.transform.SetParent(_Canvas.transform); }
public void SetBlockEditorUnitRootAtSourceCodeViewer(BlockEditorUnit blockEditorUnit) { if (blockEditorUnit == null) { return; } blockEditorUnit.transform.SetParent(this.SourceCodeViewerRectTransform); }
private void InitBlockShop() { TypeFilter typeFilter = new TypeFilter(FindIBlockCategoryFilter); foreach (Type type in BlockReflector.GetAllSealedBlockTypeContainingBlockTitleAttribute()) { #if UNITY_EDITOR if (type.GetConstructor(Type.EmptyTypes) == null) { Debug.LogWarning(" \" " + type.Name + " \" Dont Have Default Constructor"); continue; // If Type don't have default constructor, continue loop } if (type.GetCustomAttribute(typeof(NotAutomaticallyMadeOnBlockShopAttribute), true) != null) { Debug.LogWarning(" \" " + type.Name + " \" Containing NotAutomaticallyMadeOnBlockShopAttribute"); continue; } #endif BlockEditorUnit createdBlockEditorUnit = BlockEditorManager.instnace.CreateBlockEditorUnit(type, this, this.BlockShopContent); if (createdBlockEditorUnit != null) { createdBlockEditorUnit._BlockEditorUnitFlag = BlockEditorUnit.ShopBlockFlag; Type[] interfaces = type.FindInterfaces(typeFilter, null); if (interfaces.Length > 0) { if (BlockEditorUnitsInBlockShop.ContainsKey(interfaces[0]) == false) { this.BlockEditorUnitsInBlockShop[interfaces[0]] = new List <BlockEditorUnit>(); } BlockEditorUnitsInBlockShop[interfaces[0]].Add(createdBlockEditorUnit); } else { Debug.LogError("Please Add BlockMainCategoryAttribute To : " + type.FullName); } } } this.SortBlockEditorUnitsInBlockShop(); }
public void ShowIsAttachable(BlockEditorUnit attachedBlockEditorUnit = null) { FlowBlockEditorUnit flowBlockEditorUnit = attachedBlockEditorUnit as FlowBlockEditorUnit; if (flowBlockEditorUnit != null) { this.CreateFlowBlockMockUp(flowBlockEditorUnit); //If this FlowBlockConnector is UpNotch Type, MockUpHeight if (_ConnectorType == FlowBlockConnector.ConnectorType.UpNotch) { this.SetRectHeightScaling(flowBlockEditorUnit.DescendantBlockCount + 2); } } else { this.SetRectHeightScaling(1); } }
public bool AddToSpawnedBlockEditorUnitInSourceCode(BlockEditorUnit blockEditorUnit) { if (blockEditorUnit.TargetBlock == null) { Debug.LogError("blockEditorUnit.TargetBlock is null"); return(false); } if (this.SpawnedBlockEditorUnitInSourceCode == null) { this.SpawnedBlockEditorUnitInSourceCode = new Dictionary <Block, BlockEditorUnit>(); } if (this.SpawnedBlockEditorUnitInSourceCode.ContainsKey(blockEditorUnit.TargetBlock) == true) { return(false); } this.SpawnedBlockEditorUnitInSourceCode.Add(blockEditorUnit.TargetBlock, blockEditorUnit); return(true); }
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); } } } }
/// <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); }
public void ShowIsAttachable(BlockEditorUnit attachedBlockEditorUnit = null) { _Image.color = attachedBlockEditorUnit != null ? attachedBlockEditorUnit.BlockColor : Color.white; }
private BlockEditorUnit DuplicateBlockEditorUnit(BlockEditorUnit blockEditorUnit, Transform parent) { BlockEditorUnit createdBlockEditorUnit = blockEditorUnit.Duplicate(parent); return(createdBlockEditorUnit); }
private void Awake() { targetBlockEditorUnit = target as BlockEditorUnit; }