public static void Destroy(MaskableGraphic graphic) { var s = graphic.GetComponent <T>(); if (s != null) { Shadow.DestroyImmediate(s); } }
public void Apply(MaskableGraphic graphic) { var t = graphic.GetComponent <T>(); if (t == null) { t = graphic.gameObject.AddComponent <T>(); } ApplyEffect(t); }
/// <summary> /// Changes the user interface mesh. /// </summary> /// <param name="uiMeshName">User interface mesh name.</param> /// <param name="texture">Texture.</param> /// <param name="mat">Mat.</param> public void ChangeUIMesh(string uiMeshName, Texture texture, Material mat = null) { MaskableGraphic attachment = GetUIAttachmentByName(uiMeshName); if (!attachment) { return; } UIMesh um = attachment.GetComponent <UIMesh>(); ChangeUIMesh(um, texture, mat); }
public void CopyFrom(MaskableGraphic graphic) { UnityEngine.RectTransform rect = graphic.GetComponent <RectTransform>(); SyncScale = rect.localScale.x; ScaleDelta = rect.localScale; SyncSize = rect.sizeDelta.x; SizeDelta = rect.sizeDelta; Position = rect.anchoredPosition3D; Rotation = rect.eulerAngles.z; Color = graphic.color; }
public static TableGameDragSensor Init(MaskableGraphic target, IDragSensorManager manager, int id) { var sensor = target.GetComponent <TableGameDragSensor>(); if (sensor == null) { sensor = target.gameObject.AddComponent <TableGameDragSensor>(); } sensor.manager = manager; sensor.id = id; return(sensor); }
/// <summary> /// Changes the user interface mesh. /// </summary> /// <param name="uiMeshName">User interface mesh name.</param> /// <param name="newTextureFrameName">New texture frame name.</param> public void ChangeUIMesh(string uiMeshName, string newTextureFrameName) { MaskableGraphic attachment = GetUIAttachmentByName(uiMeshName); if (!attachment) { return; } UIMesh um = attachment.GetComponent <UIMesh>(); TextureFrame frame = textureFrames.GetTextureFrame(newTextureFrameName); if (um != null && frame != null) { um.frame = frame; } }
/// <summary> /// Changes the user interface frame. /// </summary> /// <param name="uiFrameName">User interface frame name.</param> /// <param name="newFrameName">New frame name.</param> public void ChangeUIFrame(string uiFrameName, string newFrameName) { MaskableGraphic attachment = GetUIAttachmentByName(uiFrameName); if (!attachment) { return; } UIFrame uf = attachment.GetComponent <UIFrame>(); TextureFrame frame = textureFrames.GetTextureFrame(newFrameName); if (uf != null && frame != null) { uf.frame = frame; } }
// change UI=================== /// <summary> /// Changes the user interface frame. /// </summary> /// <param name="uiFrameName">User interface frame name.</param> /// <param name="texture">Texture.</param> /// <param name="mat">Mat.</param> public void ChangeUIFrame(string uiFrameName, Texture texture, Material mat = null) { if (string.IsNullOrEmpty(uiFrameName) || !texture) { return; } MaskableGraphic uiAttachment = GetUIAttachmentByName(uiFrameName); if (!uiAttachment) { return; } UIFrame sf = uiAttachment.GetComponent <UIFrame>(); ChangeUIFrame(sf, texture, mat); }
public static void ApplySnapshotLerp(MaskableGraphic graphic, GraphicState state, TransitionParameters transition, GraphicSnapshot origin, GraphicSnapshot target, float t) { RectTransform rect = graphic.GetComponent <RectTransform>(); float progress = 0; if (state.ChangeSize == true) { UpdateProgress(ref progress, t, state.Size_SeparateTransition, transition.SizeUseCurve, transition.SizeCurve, transition.SizePower, transition.UseCurve, transition.Curve, transition.Power); if (state.SyncSizeAxises == true) { rect.sizeDelta = Vector2.one * Mathf.LerpUnclamped(origin.SyncSize, target.SyncSize, progress); } else { rect.sizeDelta = Vector2.LerpUnclamped(origin.SizeDelta, target.SizeDelta, progress); } } if (state.ChangeScale == true) { UpdateProgress(ref progress, t, state.Scale_SeparateTransition, transition.ScaleUseCurve, transition.ScaleCurve, transition.ScalePower, transition.UseCurve, transition.Curve, transition.Power); if (state.SyncScaleAxises == true) { rect.localScale = Vector3.one * Mathf.LerpUnclamped(origin.SyncScale, target.SyncScale, progress); } else { rect.localScale = Vector3.LerpUnclamped(origin.ScaleDelta, target.ScaleDelta, progress); } } if (state.ChangePosition == true) { UpdateProgress(ref progress, t, state.Position_SeparateTransition, transition.PositionUseCurve, transition.PositionCurve, transition.PositionPower, transition.UseCurve, transition.Curve, transition.Power); rect.anchoredPosition3D = Vector3.LerpUnclamped(origin.Position, target.Position, progress); } if (state.ChangeRotation == true) { UpdateProgress(ref progress, t, state.Rotation_SeparateTransition, transition.RotationUseCurve, transition.RotationCurve, transition.RotationPower, transition.UseCurve, transition.Curve, transition.Power); rect.localEulerAngles = rect.localEulerAngles.SetZ(Mathf.LerpUnclamped(origin.Rotation, target.Rotation, progress)); } if (state.ChangeColor == true) { UpdateProgress(ref progress, t, state.Color_SeparateTransition, transition.ColorUseCurve, transition.ColorCurve, transition.ColorPower, transition.UseCurve, transition.Curve, transition.Power); graphic.color = Color.LerpUnclamped(origin.Color, target.Color, progress); } }
void Start() { rectTransform = image.GetComponent <RectTransform>(); message = transform.Find("Message").GetComponent <Text>().text; }
/// <summary> /// Sets to pose. /// </summary> public void SetToPose() { if (poseData) { for (int i = 0; i < poseData.boneDatas.Length && i < bones.Length; ++i) { Transform bone = bones[i]; if (bone) { PoseData.TransformData transData = poseData.boneDatas[i]; bone.localPosition = new Vector3(transData.x, transData.y, bone.localPosition.z); bone.localScale = new Vector3(transData.sx, transData.sy, bone.localScale.z); bone.localEulerAngles = new Vector3(bone.localEulerAngles.x, bone.localEulerAngles.y, transData.rotation); } } for (int i = 0; i < poseData.slotDatas.Length && i < slots.Length; ++i) { Slot slot = slots[i]; if (slot) { slot.color = poseData.slotDatas[i].color; slot.displayIndex = poseData.slotDatas[i].displayIndex; slot.z = poseData.slotDatas[i].zorder; } m_SortedSlots = null; } if (isUGUI) { for (int i = 0; i < poseData.displayDatas.Length && i < uiAttachments.Length; ++i) { MaskableGraphic mg = uiAttachments[i]; if (mg) { PoseData.DisplayData displayData = poseData.displayDatas[i]; switch (displayData.type) { case PoseData.AttachmentType.IMG: UIFrame uf = mg.GetComponent <UIFrame>(); if (uf) { uf.color = displayData.color; } else { Image img = mg.GetComponent <Image>(); if (img) { img.color = displayData.color; } } break; case PoseData.AttachmentType.MESH: UIMesh um = mg.GetComponent <UIMesh> (); um.vertices = (Vector3[])displayData.vertex.Clone(); if (um.vertControlTrans != null && um.vertControlTrans.Length > 0) { for (int j = 0; j < um.vertControlTrans.Length && j < um.vertices.Length; ++j) { Transform vctr = um.vertControlTrans [j]; if (vctr) { vctr.localPosition = um.vertices [j]; } } } break; } } } } else { for (int i = 0; i < poseData.displayDatas.Length && i < attachments.Length; ++i) { Renderer r = attachments[i]; if (r) { PoseData.DisplayData displayData = poseData.displayDatas[i]; switch (displayData.type) { case PoseData.AttachmentType.IMG: SpriteFrame sf = r.GetComponent <SpriteFrame>(); if (sf) { sf.color = displayData.color; } else { SpriteRenderer sr = r.GetComponent <SpriteRenderer>(); if (sr) { sr.color = displayData.color; } } break; case PoseData.AttachmentType.MESH: SpriteMesh sm = r.GetComponent <SpriteMesh>(); sm.vertices = (Vector3[])displayData.vertex.Clone(); if (sm.vertControlTrans != null) { for (int j = 0; j < sm.vertControlTrans.Length && j < sm.vertices.Length; ++j) { Transform vctr = sm.vertControlTrans[j]; if (vctr) { vctr.localPosition = sm.vertices[j]; } } } break; } } } } } ResetSlotZOrder(); }