private void InstantiateSegment(int quantity) { int count = segments.Count; if (count == quantity) { return; } else if (count < quantity) { for (int i = 0; i < quantity - count; ++i) { GameObject g = Instantiate(SegmentPrefab, transform); ArcArcSegmentComponent component = g.GetComponent <ArcArcSegmentComponent>(); component.Enable = Enable; component.Alpha = Alpha; component.Highlight = Highlight; component.Selected = Selected; segments.Add(component); } } else if (count > quantity) { for (int i = 0; i < count - quantity; ++i) { Destroy(segments.Last().gameObject); segments.RemoveAt(segments.Count - 1); } } foreach (ArcArcSegmentComponent s in segments) { s.transform.SetAsLastSibling(); } }
public void SetArcBodySkin(Texture2D normal, Texture2D highlight) { ArcMaterial.mainTexture = normal; ArcArcRenderer prefabRenderer = ArcNotePrefab.GetComponent <ArcArcRenderer>(); prefabRenderer.HighlightTexture = highlight; prefabRenderer.DefaultTexture = normal; prefabRenderer.ReloadSkin(); ArcArcSegmentComponent prefabSegmentComponent = prefabRenderer.SegmentPrefab.GetComponent <ArcArcSegmentComponent>(); prefabSegmentComponent.HighlightTexture = highlight; prefabSegmentComponent.DefaultTexture = normal; prefabSegmentComponent.ReloadSkin(); foreach (ArcArc arc in Arcs) { arc.arcRenderer.HighlightTexture = highlight; arc.arcRenderer.DefaultTexture = normal; arc.arcRenderer.ReloadSkin(); } }
private void UpdateHead() { if (!IsHead) { EnableHead = false; return; } int currentTiming = ArcGameplayManager.Instance.Timing; int offset = ArcAudioManager.Instance.AudioOffset; if (arc.Position > 100000 || arc.Position < -100000) { EnableHead = false; return; } EnableHead = true; if (arc.Position > 90000 && arc.Position <= 100000) { Head.localPosition = new Vector3(); HeadRenderer.sharedMaterial = arcMaterial; Color highC = currentHighColor; highC.a = currentHighColor.a * (100000 - arc.Position) / 100000; Color lowC = currentLowColor; lowC.a = currentLowColor.a * (100000 - arc.Position) / 100000; HeadRenderer.GetPropertyBlock(headPropertyBlock); headPropertyBlock.SetColor(highColorShaderId, highC); headPropertyBlock.SetColor(lowColorShaderId, lowC); HeadRenderer.SetPropertyBlock(headPropertyBlock); } else if (arc.Timing + offset < currentTiming) { HeadRenderer.GetPropertyBlock(headPropertyBlock); headPropertyBlock.SetColor(highColorShaderId, currentHighColor); headPropertyBlock.SetColor(lowColorShaderId, currentLowColor); HeadRenderer.SetPropertyBlock(headPropertyBlock); if (arc.Judging || arc.IsVoid) { if (segmentCount >= 1) { ArcArcSegmentComponent s = segments[0]; int duration = s.ToTiming - s.FromTiming; if (duration == 0) { EnableHead = false; return; } float t = duration == 0 ? 0 : ((-arc.Position / 1000f) / (-s.ToPos.z)); if (t > 1) { EnableHead = false; return; } else if (t < 0) { t = 0; } Head.localPosition = (s.ToPos - s.FromPos) * t; } } else { Head.localPosition = new Vector3(); } } else { HeadRenderer.GetPropertyBlock(headPropertyBlock); headPropertyBlock.SetColor(highColorShaderId, currentHighColor); headPropertyBlock.SetColor(lowColorShaderId, currentLowColor); HeadRenderer.SetPropertyBlock(headPropertyBlock); Head.localPosition = new Vector3(); } }