SetBlendMaterial() public method

public SetBlendMaterial ( Texture texture ) : void
texture UnityEngine.Texture
return void
示例#1
0
        private void OnPointerEnterAttached(PointerEventData data)
        {
                        #if LOG
            Debug.Log("OnPointerEnterAttached " + this.name);
                        #endif

            if (data.pointerPress != null)
            {
                Item dragItem = data.pointerPress.GetComponent <Item>();
                if (dragItem != null && dragItem.HasTag("Color"))
                {
                    Item item = GetComponent <Item>();
                    _initialBlendTexture = item.BlendMaterialArray[0].GetTexture("_Blend");
                    item.SetBlendMaterial(dragItem.MaterialArray[0].mainTexture);
                }
            }
        }
        private void OnPointerUpInstantiate(PointerEventData data)
        {
                        #if LOG
            Debug.Log("OnPointerUpAttachedHighlighted " + this.name);
                        #endif

            VisualizationUI plannerUI            = FindObjectOfType <VisualizationUI>();
            Item            instantiatedItem     = plannerUI.InstantiateSelectedItem(data);
            ItemDrag        instantiatedItemDrag = instantiatedItem.GetComponent <ItemDrag>();
            ItemDrop        itemDrop             = GetComponent <ItemDrop>();
            if (itemDrop != null)
            {
                instantiatedItemDrag.ThisEnteredDropItem = itemDrop;
                instantiatedItemDrag.ParentItemDrop      = itemDrop;

                ItemSnap itemSnap = instantiatedItemDrag.NearestItemSnap(data);
                instantiatedItemDrag.ParentItemSnap = itemSnap;
                Ray ray = itemSnap.Snap(instantiatedItem, data);
                instantiatedItemDrag.SetTargetPositionRotation(ray.origin, ray.direction);
                //set to outline and normal to get rid of quirk where instantied shader isn't immediately properly lit
                instantiatedItem.SetShaderOutline(_itemSettings.InstantiateOutlineColor);
                instantiatedItem.SetShaderNormal();
                instantiatedItem.State = ItemState.NoInstantiate;

                //TODO this should always be able to attach, why are we checking?
                if (itemDrop.CanAttach(instantiatedItem.TagArray))
                {
                    SetShaderOutline(_itemSettings.InstantiateOutlineColor);
                }
                else
                {
                    SetShaderNormal();
                    State = ItemState.NoInstantiate;
                }
            }
            ItemColor itemColor = GetComponent <ItemColor>();
            if (itemColor != null)
            {
                Item item = GetComponent <Item>();
                item.SetBlendMaterial(instantiatedItem.MaterialArray[0].mainTexture);
                SetShaderNormal();
                State = ItemState.NoInstantiate;
                StartCoroutine(instantiatedItem.DestroyItemCoroutine());
            }
        }