Esempio n. 1
0
        public static void AddMaterialToList(PartBundleDescriptor partBundleDesc, MaterialDescriptor matDesc, Material mat)
        {
            PartEditor.MatList matList = null;

            switch (matDesc.materialType)
            {
            case (MaterialInfo.MaterialType.Glow):
                matList = PartEditor.GlowList;
                break;

            case (MaterialInfo.MaterialType.Secondary):
                matList = PartEditor.SecondaryList;
                break;

            case (MaterialInfo.MaterialType.Trail):
                matList = PartEditor.TrailList;
                break;

            case (MaterialInfo.MaterialType.NamePlate):
                matList = PartEditor.NamePlateList;
                break;

            case (MaterialInfo.MaterialType.Template):
                matList = PartEditor.TemplateList;
                break;
            }

            string trimmedName = mat.name.Replace(" (Instance)", "");

            string matRefName = partBundleDesc.partBundleAuthor + "." + partBundleDesc.partBundleName + "." + matDesc.materialType.ToString() + "." + trimmedName;

            foreach (MaterialInfo listMatInfo in matList.mats)
            {
                if (listMatInfo.materialReferenceName == matRefName)
                {
                    Logger.log.Debug("A material with the name " + listMatInfo.materialReferenceName + " has already been added - skipping. Make sure all material and bundle names are unique!");
                    return;
                }
            }

            MaterialInfo matInfo = new MaterialInfo(matDesc.materialType, mat, matRefName, matDesc.materialDisplayName, matDesc.supportsCustomColors);

            matList.mats.Add(matInfo);
            Logger.log.Debug("Added " + matRefName + " to the list of " + matInfo.materialType.ToString() + " materials");
        }
Esempio n. 2
0
        static void SetMatListIndexFromConfig(string matName, PartEditor.MatList matList)
        {
            int matIndex = -1;

            for (int i = 0; i < matList.mats.Count; i++)
            {
                if (matList.mats[i].materialReferenceName == matName)
                {
                    matIndex = i;
                }
            }

            if (matIndex == -1)
            {
                Logger.log.Debug("Could not find saved material in loaded lists! Setting to default");
                matIndex = 0;
            }

            matList.index = matIndex;
        }
Esempio n. 3
0
        public static GameObject CreateMaterialSwapPanel(Transform parent, PartEditor.MatList matList, string panelLabel)
        {
            RectTransform newPanel = CreateRectPanel(parent, panelLabel);

            TextMeshProUGUI matNameText = BeatSaberUI.CreateText(newPanel, "mat name", new Vector2(20, 0), new Vector2(30, 10));

            matNameText.alignment = TextAlignmentOptions.Center;
            matNameText.fontSize  = 4;

            HoverHint matHoverHint = BeatSaberUI.AddHintText(matNameText.gameObject.GetComponent <RectTransform>(), "hint");

            LabelTextGroup textGroup = new LabelTextGroup(matNameText, matHoverHint, matList);

            matTextGroups.Add(textGroup);

            //cry
            BeatSaberUI.CreateUIButton(newPanel, "DecButton", new Vector2(0, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughMatList(-1, matList); });
            BeatSaberUI.CreateUIButton(newPanel, "IncButton", new Vector2(50, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughMatList(1, matList); });

            //to set name and hint strings
            UpdateMatLabelText(textGroup);

            return(newPanel.gameObject);
        }
Esempio n. 4
0
 public LabelTextGroup(TextMeshProUGUI label, HoverHint hint, PartEditor.MatList list)
 {
     labelTMP  = label;
     hoverHint = hint;
     matList   = list;
 }