示例#1
0
 public static void HideAllTexts()
 {
     foreach (KeyValuePair <BaseLabel, int> pair in LabelsBucket.GetLabels())
     {
         Instance.HideText(pair.Value);
     }
 }
 void Start()
 {
     SetupEnv();
     totalUniqueLabels = labeledNames.Count;
     CsvWriter.SaveLabels(LabelsBucket.GetLabels().Select(pair => pair.Key).ToList());
     Debug.Log("Total Labeled items: " + totalLabeledItems + " of which unique: " + totalUniqueLabels + " total void items: " + totalVoids);
 }
    void TrySetLabelMat(Transform tr)
    {
        Renderer rend = tr.GetComponent <Renderer>();

        if (rend != null)
        {
            Material[] curMats = rend.materials;
            for (int i = 0; i < rend.materials.Length; i++)
            {
                curMats[i] = new Material(labelMaterial);
                LabelIdentity identity = rend.GetComponent <LabelIdentity>();
                int           colVal   = 0;
                if (identity != null)
                {
                    colVal = LabelsBucket.GetLabelIndex(identity) + 1;
                    totalLabeledItems++;
                    if (!labeledNames.Contains(identity.labelName))
                    {
                        labeledNames.Add(identity.labelName);
                    }
                }
                else
                {
                    Debug.Log("identity component not found on: " + tr.name + " each renderable must have an LabelIdentity component with a type set. Setting to void Val=[0]");
                    totalVoids++;
                }
                curMats[i].color = new Color32((byte)colVal, (byte)colVal, (byte)colVal, 255);
            }
            rend.materials = curMats;
        }
        else
        {
            //Debug.Log("MechRenderer not found on: " + tr.name + " , won't set.");
        }
    }
示例#4
0
    public static string LabelColors()
    {
        LabelClass labelClass      = new LabelClass();
        int        len             = LabelsBucket.GetLabels().Count;
        int        labelClassIndex = 0;

        labelClass.colors = new Color32[len];
        labelClass.labels = new int[len];
        foreach (KeyValuePair <BaseLabel, int> pair in LabelsBucket.GetLabels())
        {
            labelClass.labels[labelClassIndex] = pair.Value;
            if (LabelMaskCoordinator.HasState(pair.Key.labelName))
            {
                labelClass.colors[labelClassIndex] = pair.Key.encoderColor;
            }
            else
            {
                labelClass.colors[labelClassIndex] = new Color32(0, 0, 0, 0);
            }

            //Debug.Log(pair.Key.encoderColor + " " + pair.Value + " " + pair.Key.labelName);
            labelClassIndex += 1;
        }

        labelClass.mime = "mimey";
        string json = JsonUtility.ToJson(labelClass);

        return(json);
    }
示例#5
0
    void Start()
    {
        foreach (KeyValuePair <BaseLabel, int> pair in LabelsBucket.GetLabels())
        {
            GameObject newText = Instantiate(textPrefab);
            newText.transform.parent = transform;
            newText.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;
            newText.GetComponent <RectTransform>().offsetMin        = Vector3.zero;
            newText.GetComponent <RectTransform>().offsetMax        = Vector3.zero;

            newText.GetComponent <TextMeshProUGUI>().text  = pair.Key.labelName;
            newText.GetComponent <TextMeshProUGUI>().color = pair.Key.encoderColor;
            labelTexts[pair.Value] = newText;
            allIds.Add(pair.Value);
        }
        HideAllTexts();
    }