public void InitCamo(CamoInfo info, float d, bool selected)
        {
            Alpha           = GetComponent <CanvasGroup>();
            Alpha.alpha     = 0;
            CamoImg.texture = info.Preview;
            ID = info.ID;
            StartCoroutine(Fade(d));
#if SHOP && ULSP
            GlobalCamo gc = bl_CustomizerData.Instance.GlobalCamos[info.GlobalID];
            if (gc.Price > 0 && bl_DataBase.Instance != null)
            {
                if (bl_DataBase.Instance.LocalUser.ShopData.isItemPurchase(ShopItemType.WeaponCamo, info.GlobalID))
                {
                    blockUI.SetActive(false);
                    GetComponentInChildren <Button>().interactable = !selected;
                }
                else
                {
                    PriceText.text = "$" + gc.Price;
                    GetComponentInChildren <Button>().interactable = false;
                    blockUI.SetActive(true);
                }
            }
#else
            GetComponentInChildren <Button>().interactable = !selected;
            blockUI.SetActive(false);
#endif
        }
Пример #2
0
        /// <summary>
        /// OnEnable use this object to see if it was active
        /// verify whether the manager has the information and if not,
        /// activate the first object in the list
        /// </summary>
        void OnEnable()
        {
            if (!firstApply)
            {
                AttachmentsIDs = bl_CustomizerData.Instance.LoadAttachmentsForWeapon(WeaponName);
                CamoRender.ApplyCamo(WeaponName, AttachmentsIDs[4]);
                firstApply = true;
            }
            if (WeaponInfo != null)
            {
#if SHOP && ULSP
                for (int i = 0; i < WeaponInfo.Camos.Count; i++)
                {
                    CamoInfo   info = WeaponInfo.Camos[i];
                    GlobalCamo gc   = bl_CustomizerData.Instance.GlobalCamos[info.GlobalID];
                    if (gc.Price > 0 && bl_DataBase.Instance != null)
                    {
                        if (bl_DataBase.Instance.LocalUser.ShopData.isItemPurchase(ShopItemType.WeaponCamo, info.GlobalID))
                        {
                            availableCamos.Add(i);
                        }
                    }
                    else
                    {
                        availableCamos.Add(i);
                    }
                }
#else
                for (int i = 0; i < WeaponInfo.Camos.Count; i++)
                {
                    availableCamos.Add(i);
                }
#endif
            }
        }
Пример #3
0
 public void SetInfo(CamoInfo _info)
 {
     Info = _info;
 }
Пример #4
0
        // Draw the property inside the given rect
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            // Using BeginProperty / EndProperty on the parent property means that
            // prefab override logic works on the entire property.
            EditorGUI.BeginProperty(position, label, property);

            // Draw label
            position.x     += 25;
            position.width -= 30;
            GUI.Box(position, GUIContent.none);
            Rect headerRect = position;

            headerRect.height = EditorGUIUtility.singleLineHeight;;
            if (property.isExpanded)
            {
                CamoInfo ci = bl_CustomizerData.Instance.Weapons[property.FindPropertyRelative("ofWeaponID").intValue].Camos[property.FindPropertyRelative("ID").intValue];
                if (ci != null && ci.Preview != null)
                {
                    Rect pr = position;
                    pr.y      += EditorGUIUtility.singleLineHeight + 2;
                    pr.height -= EditorGUIUtility.singleLineHeight + 2;
                    pr.width   = pr.height;
                    GUI.DrawTexture(pr, ci.Preview, ScaleMode.StretchToFill);
                    position.x     += pr.width + 2 - 20;
                    position.width -= pr.width + 2 - 20;
                }
            }
            position.height = EditorGUIUtility.singleLineHeight;
            if (GUI.Button(headerRect, label.text, EditorStyles.toolbarPopup))
            {
                property.isExpanded = !property.isExpanded;
            }
            if (property.isExpanded)
            {
                Rect defaultRect = position;
                // Don't make child fields be indented
                var indent = EditorGUI.indentLevel;
                EditorGUI.indentLevel = 0;

                SerializedProperty giProp = property.FindPropertyRelative("GlobalID");
                int globalID = giProp.intValue;
                defaultRect.y     += EditorGUIUtility.singleLineHeight + 4;
                defaultRect.x     += 20;
                defaultRect.width -= 25;
                defaultRect.height = EditorGUIUtility.singleLineHeight;
                globalID           = EditorGUI.Popup(defaultRect, "Global ID", globalID, bl_CustomizerData.Instance.GetGlobalCamosStringArray(), EditorStyles.toolbarDropDown);
                giProp.intValue    = globalID;

                GlobalCamo         gc       = null;
                SerializedProperty nameProp = property.FindPropertyRelative("Name");
                if (globalID <= bl_CustomizerData.Instance.GlobalCamos.Count - 1)
                {
                    gc = bl_CustomizerData.Instance.GlobalCamos[globalID];
                    nameProp.stringValue = gc.Name;
                }

                defaultRect.y += EditorGUIUtility.singleLineHeight + 4;
                EditorGUI.PropertyField(defaultRect, property.FindPropertyRelative("Camo"));
                defaultRect.y += EditorGUIUtility.singleLineHeight + 2;
                EditorGUI.PropertyField(defaultRect, property.FindPropertyRelative("OverridePreview"));

                // Set indent back to what it was
                EditorGUI.indentLevel = indent;
            }

            EditorGUI.EndProperty();
            if (GUI.changed)
            {
                property.serializedObject.ApplyModifiedProperties();
            }
        }