protected void setupDragIcon(CustomizerGestureModel currentGesture) { dragContainer.SetImage(Sprite.Create(dragTexture, new Rect(0f, 0f, dragTexture.width, dragTexture.height), default(Vector2))); (dragContainer.transform as RectTransform).anchoredPosition = currentGesture.TouchDownStartPos; setRelativeIconPostion(currentGesture.TouchDownStartPos); dragContainer.Show(); }
private void ShowDragContainer() { dragContainer.Show(); Service.Get <EventDispatcher>().DispatchEvent(default(ObjectManipulationEvents.BeginDragInventoryItem)); }
protected void onDrag(Vector2 touchPosition) { if (dragContainer == null) { return; } bool flag = true; float num = 1136f; GameObject gameObject = GameObject.FindWithTag("UIHud"); if (gameObject != null) { num = gameObject.GetComponentInChildren <CanvasScalerExt>().ReferenceResolutionY; } bool flag2 = PlatformUtils.GetPlatformType() == PlatformType.Standalone; Vector2 vector = touchPosition; if (!flag2) { vector += DragIconOffset * ((float)Screen.height / num); } Ray ray = mainCamera.ScreenPointToRay(vector); if (Physics.Raycast(ray, out var hitInfo)) { GameObject gameObject2 = hitInfo.collider.gameObject; SkinnedMeshRenderer component = gameObject2.GetComponent <SkinnedMeshRenderer>(); if (component != null && component.sharedMaterial.shader.name.Contains("Equipment")) { lastTouchedPosition = touchPosition; Texture2D texture2D = gameObject2.GetComponent <SkinnedMeshRenderer>().sharedMaterial.GetTexture(EquipmentShaderParams.DECALS_123_OPACITY_TEX) as Texture2D; if (texture2D == null) { Log.LogErrorFormatted(this, "Unable to retrieve decal 123 map on item {0}. Property did not exist {1}.", gameObject2.name, EquipmentShaderParams.DECALS_123_OPACITY_TEX); return; } Vector2 textureCoord = hitInfo.textureCoord; textureCoord.Scale(new Vector2(texture2D.width, texture2D.height)); Color pixel = texture2D.GetPixel((int)textureCoord.x, (int)textureCoord.y); if (Mathf.Abs(pixel.r) < Mathf.Epsilon && Mathf.Abs(pixel.g) < Mathf.Epsilon && Mathf.Abs(pixel.b) < Mathf.Epsilon) { flag = true; } else if (pixel.r > pixel.g && pixel.r > pixel.b) { dragChannelRed(hitInfo.textureCoord, component); flag = false; } else if (pixel.g > pixel.r && pixel.g > pixel.b) { dragChannelGreen(hitInfo.textureCoord, component); flag = false; } else { dragChannelBlue(hitInfo.textureCoord, component); flag = false; } } } if (flag) { dragContainer.Show(); setRelativeIconPostion(touchPosition); if (channelUpdated != 0) { dragChannelNone(); } } else { dragContainer.Hide(instant: true); } }