public void ChangeLabelPrefab() { //set prefab dirty if (labelPrefab == null) { labelPrefab = Resources.Load <GameObject>("Prefabs/Label") as GameObject; } LabelTextManager prefabLabelManager = labelPrefab.GetComponent <LabelTextManager>(); Undo.RecordObject(labelPrefab.transform, "make change to the line width, txetwindow and dot size"); prefabLabelManager.SetDotSize(dotSize); prefabLabelManager.SetTextWindowSize(textWindowSize); prefabLabelManager.SetLineWidth(lineWidthMultiplier); prefabLabelManager.SetTextColor(textColor); PrefabUtility.RecordPrefabInstancePropertyModifications(labelPrefab.transform); //change line width, color, window size and text size in exsisting labels if (labels.Count > 0) { labels.ForEach(x => { x.SetDotSize(dotSize); x.SetTextWindowSize(textWindowSize); x.SetLineWidth(lineWidthMultiplier); x.SetTextColor(textColor); }); } }
public void DeleteLastLabel() { if (labels.Count > 0) { LabelTextManager lastLabel = labels[labels.Count - 1]; lastLabel.DeleteLabel(); } }
private void OnEnable() { mytarget = (LabelTextManager)target; upperTextmeshProperty = serializedObject.FindProperty("upperTextmesh"); bottomTextmeshProperty = serializedObject.FindProperty("bottomTextmesh"); indexTextmeshProperty = serializedObject.FindProperty("indexTextmesh"); lineProperty = serializedObject.FindProperty("line"); dotGroupProperty = serializedObject.FindProperty("dotGroup"); textGroupProperty = serializedObject.FindProperty("textGroup"); }
public void AddLabel(Vector3 dotPosition, Vector3 surfaceNormal) { if (!string.IsNullOrEmpty(bottomText)) { if (labelPrefab == null) { labelPrefab = Resources.Load <GameObject>("Prefabs/Label") as GameObject; } GameObject newlabel = Instantiate(labelPrefab, this.transform); LabelTextManager newLabelManager = newlabel.GetComponent <LabelTextManager>(); if (index == 0) { index = labels.Count + 1; } textWindowPosition = dotPosition + surfaceNormal * 0.1f; //textWindowPosition = Vector3.Reflect(dotPosition, surfaceNormal * 0.05f); newLabelManager.NewLabel(index, upperText, bottomText, dotPosition, textWindowPosition, showAllLabel); labels.Add(newLabelManager); } }