예제 #1
0
 internal void DeleteLabel(LabelAction labelAction)
 {
     if (this.labels.ContainsKey(labelAction.name))
     {
         LabelAction label      = this.labels[labelAction.name];
         int         labelIndex = this.labelActions.IndexOf(label);
         if (labelIndex < 0)
         {
             Debug.Log("Cannot find toggle index for label: " + label.name);
         }
         else
         {
             this.labels.Remove(label.name);
             this.labelActions.Remove(label);
             label.GetComponent <LabelAction>().selectLabels = null;
             label.transform.SetParent(null);
             Destroy(label);
             for (int i = 0; i < this.labelActions.Count; i++)
             {
                 PositionLabel(i, this.labelActions[i]);
             }
         }
     }
     else
     {
         Debug.Log("Could not find label to delete: " + labelAction.name);
     }
 }
예제 #2
0
        internal void AddLabel(int labelIndex, string name, Color color)
        {
            name = MakeNameUnique(name);
            Debug.Log(string.Format("Creating label '{1}' at index {0} with color '{2}'", labelIndex, name, color));
            GameObject toggleObject = (GameObject)Instantiate(Resources.Load("LabelToggle"));
            Toggle     toggle       = toggleObject.GetComponent <Toggle>();

            toggle.name = name;
            toggle.isOn = false;
            toggle.transform.SetParent(this.toggleGroup.transform);
            toggle.group = this.toggleGroup;
            toggle.GetComponentInChildren <Text>().text = name;
            Image colorImage = toggle.transform.Find("Color").GetComponent <Image>();

            colorImage.color = color;
            LabelAction labelAction = toggleObject.AddComponent <LabelAction>();

            labelAction.selectLabels = this;
            PositionLabel(labelIndex, labelAction);
            Button deleteButton = toggle.transform.Find("X").GetComponent <Button>();

            deleteButton.onClick.AddListener(labelAction.DeleteLabel);
            this.labels.Add(name, labelAction);
            this.labelActions.Add(labelAction);
        }
예제 #3
0
        private void PositionLabel(int labelIndex, LabelAction labelAction)
        {
            RectTransform toggleTransform = labelAction.GetComponent <RectTransform>();

            toggleTransform.localEulerAngles = Vector3.zero;
            toggleTransform.localScale       = Vector3.one;
            toggleTransform.localPosition    = new Vector3(this.labelX, this.labelYTop - this.labelYGap * labelIndex, 0);
        }
예제 #4
0
        internal Color GetSelectedLabelColor()
        {
            LabelAction selected = GetSelectedLabelAction();

            if (selected != null)
            {
                return(selected.GetColor());
            }
            Debug.Log("Unable to find a selected label color");
            return(UnityEngine.Random.ColorHSV());
        }
        public NodeObject MakeOne(float x, float y, float z)
        {
            NodeObject node = MakeNode("unknown", new Vector3(x, y, z), GetColor());

            if (selectLabels != null)
            {
                LabelAction selectedLabel = selectLabels.GetSelectedLabelAction();
                if (selectedLabel != null)
                {
                    node.label = selectedLabel.name;
                }
            }
            //DebugSphere(node, "Created");
            return(node);
        }
예제 #6
0
 public Label(int labelId, LabelAction labelAction)
 {
     this.labelId = labelId;
     this.name    = labelAction.name;
     this.color   = labelAction.GetColor();
 }