protected override void OnItemLeave(object userData, string type) { base.OnItemLeave(userData, type); RadarEventArgs args = userData as RadarEventArgs; foreach (BillboardText t in mActiveTexts) { foreach (ChartItemEffect effect in t.UIText.GetComponents <ChartItemEffect>()) { if (t.UIText == null) { continue; } effect.TriggerOut(false); } } mActiveTexts.Clear(); string category = args.Category; mOccupiedCateogies.Remove(category); mOccupiedCateogies.RemoveWhere(x => !Data.HasCategory(x)); if (mOccupiedCateogies.Count == 0) { if (NonHovered != null) { NonHovered.Invoke(); } } }
private void Points_Hover(string category, int index, Vector2 position) { index = index % DataSource.TotalGroups; string group = DataSource.GetGroupName(index); double amount = DataSource.GetValue(category, group); RadarEventArgs args = new RadarEventArgs(category, group, amount, position, index); OnItemHoverted(args); }
protected override void OnItemSelected(object userData) { base.OnItemSelected(userData); RadarEventArgs args = userData as RadarEventArgs; if (args == null) { return; } mOccupiedCateogies.Add(args.Category); if (PointClicked != null) { PointClicked.Invoke(args); } }
protected override void OnItemHoverted(object userData) { base.OnItemHoverted(userData); List <BillboardText> catgoryTexts; RadarEventArgs args = userData as RadarEventArgs; if (args == null) { return; } foreach (BillboardText t in mActiveTexts) { if (t.UIText == null) { continue; } foreach (ChartItemEffect effect in t.UIText.GetComponents <ChartItemEffect>()) { effect.TriggerOut(false); } } mActiveTexts.Clear(); if (mTexts.TryGetValue(args.Category, out catgoryTexts)) { if (args.Index < catgoryTexts.Count) { BillboardText b = catgoryTexts[args.Index]; mActiveTexts.Add(b); GameObject t = b.UIText; if (t != null) { foreach (ChartItemEffect effect in t.GetComponents <ChartItemEffect>()) { effect.TriggerIn(false); } } } } mOccupiedCateogies.Add(args.Category); if (PointHovered != null) { PointHovered.Invoke(args); } }
private void Points_Leave(string category) { RadarEventArgs args = new RadarEventArgs(category, "", 0.0, Vector3.zero, 0); OnItemLeave(args, "none"); }
protected override GameObject CreateCategoryObject(Vector3[] path, int category) { RadarChartData.CategoryData cat = ((IInternalRadarData)DataSource).getCategoryData(category); GameObject container = ChartCommon.CreateChartItem(); ChartCommon.HideObject(container, hideHierarchy); container.transform.SetParent(transform, false); container.transform.localScale = new Vector3(1f, 1f, 1f); container.transform.localPosition = new Vector3(0f, 0f, cat.Seperation); container.transform.localRotation = Quaternion.identity; if (cat.FillMaterial != null) { RadarFillGenerator fill = CreateFillObject(container); fill.Smoothing = cat.FillSmoothing; Renderer rend = fill.GetComponent <Renderer>(); if (rend != null) { rend.material = cat.FillMaterial; } fill.Generate(path, Radius, cat.Curve); } if (cat.LinePrefab != null && cat.LineMaterial != null && cat.LineThickness > 0) { GameObject line = CreatePrefab(container, cat.LinePrefab.gameObject); PathGenerator pathGen = line.GetComponent <PathGenerator>(); Renderer rend = line.GetComponent <Renderer>(); if (rend != null) { rend.material = cat.LineMaterial; } pathGen.Generator(path, cat.LineThickness, true); } GameObject prefab = cat.PointPrefab; if (prefab == null) { if (mEmptyPointPrefab == null) { mEmptyPointPrefab = (GameObject)Resources.Load("Chart And Graph/SelectHandle"); } prefab = mEmptyPointPrefab; } if (prefab != null) { for (int i = 0; i < path.Length; i++) { GameObject point = CreatePrefab(container, prefab); string group = DataSource.GetGroupName(i); double value = DataSource.GetValue(cat.Name, group); RadarEventArgs args = new RadarEventArgs(cat.Name, group, value, path[i], i); point.transform.localPosition = path[i]; point.transform.localScale = new Vector3(cat.PointSize, cat.PointSize, cat.PointSize); Renderer rend = point.GetComponent <Renderer>(); if (rend != null) { rend.material = cat.PointMaterial; } ChartMaterialController controller = point.GetComponent <ChartMaterialController>(); if (controller != null && controller.Materials != null) { Color hover = controller.Materials.Hover; Color selected = controller.Materials.Selected; controller.Materials = new ChartDynamicMaterial(cat.PointMaterial, hover, selected); } ChartItemEvents[] events = point.GetComponentsInChildren <ChartItemEvents>(); for (int j = 0; j < events.Length; ++j) { if (events[j] == null) { continue; } InternalItemEvents comp = (InternalItemEvents)events[j]; comp.Parent = this; comp.UserData = args; } } } if (mCategoryLabels != null && mCategoryLabels.isActiveAndEnabled) { for (int i = 0; i < path.Length; i++) { string group = DataSource.GetGroupName(i); double val = DataSource.GetValue(cat.Name, group); Vector3 labelPos = path[i]; Vector3 dir = labelPos.normalized; labelPos += dir * mCategoryLabels.Seperation; labelPos += new Vector3(mCategoryLabels.Location.Breadth, 0f, mCategoryLabels.Location.Depth); int fractionDigits = 2; if (mItemLabels != null) { fractionDigits = mItemLabels.FractionDigits; } string toSet = mCategoryLabels.TextFormat.Format(ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, val), cat.Name, group); BillboardText billboard = ChartCommon.CreateBillboardText(null, mCategoryLabels.TextPrefab, transform, toSet, labelPos.x, labelPos.y, labelPos.z, 0f, null, hideHierarchy, mCategoryLabels.FontSize, mCategoryLabels.FontSharpness); TextController.AddText(billboard); AddBillboardText(cat.Name, billboard); } } return(container); }