public void SetSquareAlignment(int alignment) { if ((SpanAlignment)alignment == squareTimeSpan) { return; } squareTimeSpan = (SpanAlignment)alignment; dirty = true; }
public Element(string name, string group, string layer, DateTime startTime, DateTime endTime, int size, SpanAlignment guideSpan = SpanAlignment.None, bool calendarAligned = false, Color?setColor = null) { this.name = name; this.group = group; this.layer = layer; this.size = size; points = new bool[size, size]; this.guideSpan = guideSpan; this.calendarAligned = calendarAligned; instance.elementsPerLayer[layer].Add(this); RectTransform labelParentRTF = Instantiate(instance.elementLabelContainer, instance.labelLayersByName[layer]); //Debug.Log( "label parent rtf: " + labelParentRTF + "; label parent: " + labelParentRTF?.gameObject ); labelParentRTF.name = name; labelParent = labelParentRTF.gameObject; labelPrefabToUse = instance.labelPrefab; if (guideSpan == SpanAlignment.Months) { labelPrefabToUse = instance.monthLabelPrefab; } if (guideSpan == SpanAlignment.Years) { labelPrefabToUse = instance.yearLabelPrefab; } if (guideSpan == SpanAlignment.Decades) { labelPrefabToUse = instance.decadeLabelPrefab; } if (guideSpan == SpanAlignment.None) { this.color = setColor ?? MaxDifferentColor(instance.elementsPerLayer[layer].Select(e => e.color), 10); listing = Instantiate(instance.elementListingPrefab, instance.elementList); listingText = listing.GetComponentInChildren <Text>(); listingText.text = name; listingText.color = color; instance.elementsByListing[listing] = this; GroupElementListing gel = listing.GetComponentInChildren <GroupElementListing>(); gel.element = this; gel.layer = layer; if (!instance.groups.Contains(group) && group != "--") { instance.groups.Add(group); var groupListing = Instantiate(instance.groupListingPrefab, instance.groupList); groupListing.GetComponentInChildren <Text>().text = group; gel = groupListing.GetComponentInChildren <GroupElementListing>(); gel.group = group; gel.layer = layer; instance.groupListings.Add(gel); } label = Instantiate(labelPrefabToUse, labelParent.transform as RectTransform); Text labelText = label.GetComponentInChildren <Text>(); labelText.text = name; labelText.color = color.ShiftLuma(0.25f); Color backingColor = color * 0.4f; backingColor.a = 0.4f; label.GetComponentInChildren <Image>().color = backingColor; labels.Add(label); blocks.Add(new TimeBlock(startTime, endTime)); } }