Esempio n. 1
0
    public static void CheckConfig(hwmAddressablesSystemConfig config)
    {
        for (int iGroup = 0; iGroup < config.GroupRules.Length; iGroup++)
        {
            GroupRule iterGroupRule = config.GroupRules[iGroup];
            if (string.IsNullOrWhiteSpace(iterGroupRule.GroupName))
            {
                Debug.LogError(string.Format("Group-{0}的GroupName为空", iterGroupRule.GroupName));
            }

            for (int iAsset = 0; iAsset < iterGroupRule.AssetRules.Length; iAsset++)
            {
                AssetRule iterAssetRule = iterGroupRule.AssetRules[iAsset];
                if (!(iterAssetRule.Path.StartsWith("Assets") &&
                      iterAssetRule.Path.EndsWith("/")))
                {
                    Debug.LogError(string.Format("Group-{0}({1})的AssetRule-{2}的Path不是\"Assets*/\"格式", iGroup, iterGroupRule.GroupName, iAsset));
                }

                for (int iExtension = 0; iExtension < iterAssetRule.ExtensionFilters.Count; iExtension++)
                {
                    string iterExtension = iterAssetRule.ExtensionFilters[iExtension];
                    if (!iterExtension.StartsWith("."))
                    {
                        Debug.LogError(string.Format("Group-{0}({1})的AssetRule-{2}的ExtensionFilters-{3}({4})不是\".*/\"格式", iGroup, iterGroupRule.GroupName, iAsset, iExtension, iterExtension));
                    }
                }
            }
        }
        Debug.Log("Check config finish");
    }
Esempio n. 2
0
    private static hwmAddressablesSystemConfig CreateConfig()
    {
        hwmAddressablesSystemConfig config = GetConfig();

        if (config == null)
        {
            config = CreateAssetAtSelectionFolder <hwmAddressablesSystemConfig>("AddressablesSystemConfig");
        }

        return(config);
    }
Esempio n. 3
0
    private static bool SearchGroupRule(hwmAddressablesSystemConfig config, string groupName, out GroupRule groupRule)
    {
        for (int iGroupRule = 0; iGroupRule < config.GroupRules.Length; iGroupRule++)
        {
            GroupRule iterGroupRule = config.GroupRules[iGroupRule];
            if (iterGroupRule.GroupName == groupName)
            {
                groupRule = iterGroupRule;
                return(true);
            }
        }

        groupRule = new GroupRule();
        return(false);
    }
Esempio n. 4
0
    public static void GenerateAll(hwmAddressablesSystemConfig config)
    {
        AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;

        for (int iGroupRule = 0; iGroupRule < config.GroupRules.Length; iGroupRule++)
        {
            GroupRule iterGroupRule = config.GroupRules[iGroupRule];
            if (string.IsNullOrWhiteSpace(iterGroupRule.GroupName))
            {
                Debug.LogError(string.Format("Group index ({0}) name is empty", iGroupRule));
                continue;
            }

            GenerateWithGroupRule(settings, config.MyGenerateSetting, iterGroupRule);
        }
        Debug.Log("Generate all group finish");
    }
Esempio n. 5
0
    public static void GenerateSpecified(hwmAddressablesSystemConfig config)
    {
        string specifiedGroupName = config.MyGenerateSetting.SpecifiedGroupName;

        if (string.IsNullOrWhiteSpace(specifiedGroupName))
        {
            Debug.LogError("Specified group name is empty");
            return;
        }

        if (SearchGroupRule(config, specifiedGroupName, out GroupRule groupRule))
        {
            GenerateWithGroupRule(AddressableAssetSettingsDefaultObject.Settings, config.MyGenerateSetting, groupRule);
            Debug.Log(string.Format("Generate specified group ({0}) finish", specifiedGroupName));
        }
        else
        {
            Debug.LogError(string.Format("Not found specified group ({0})", specifiedGroupName));
        }
    }
Esempio n. 6
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        hwmAddressablesSystemConfig config = property.serializedObject.targetObject as hwmAddressablesSystemConfig;
        float propertyHeight = base.GetPropertyHeight(property, label);

        position.height = propertyHeight;
        if (config == null)
        {
            EditorGUI.LabelField(position, "AddressablesSystemEditorAttribute can only be used in AddressablesSystemConfig ");
        }
        else
        {
            if (GUI.Button(position, "Generate All"))
            {
                hwmAddressablesSystemUtility.GenerateAll(config);
            }

            position.y += propertyHeight + PROPERTY_SPACING_HEIGHT;
            if (GUI.Button(position, "Generate Specified"))
            {
                hwmAddressablesSystemUtility.GenerateSpecified(config);
            }

            position.y += propertyHeight + PROPERTY_SPACING_HEIGHT;
            if (GUI.Button(position, "Check Config"))
            {
                hwmAddressablesSystemUtility.CheckConfig(config);
            }

            position.y += propertyHeight + PROPERTY_SPACING_HEIGHT;
            if (GUI.Button(position, "Help"))
            {
                EditorUtility.DisplayDialog("Addressables System Config", "这么简单的东西还需要帮助?", "OK");
            }
        }
    }