Exemplo n.º 1
0
        private void RenderDropdownShaderFeature(ProfileFeatureDefinition def, out bool valueChanged)
        {
            valueChanged = false;

            int currentIndex = def.dropdownSelectedIndex;

            // State is maintained in the feature flags, so find the one that's enabled.
            for (int i = 0; i < def.featureKeys.Length; i++)
            {
                string feature = def.featureKeys[i];
                if (m_Profile.IsFeatureEnabled(feature))
                {
                    currentIndex = i;
                    break;
                }
            }

            EditorGUI.BeginChangeCheck();
            int selectedIndex = EditorGUILayout.Popup(def.name, currentIndex, def.dropdownLabels);

            if (EditorGUI.EndChangeCheck())
            {
                valueChanged = true;

                // Clear and set new shader keyword for this dropdown.
                SetShaderKeywordAndFeatureFlag(def.shaderKeywords[currentIndex], def.featureKeys[currentIndex], false);
                SetShaderKeywordAndFeatureFlag(def.shaderKeywords[selectedIndex], def.featureKeys[selectedIndex], true);
            }
        }
Exemplo n.º 2
0
        // Feature that's just a boolean flag.
        public static ProfileFeatureDefinition CreateBooleanFeature(
            string featureKey, bool value, string name,
            string dependsOnFeature, bool dependsOnValue, string tooltip)
        {
            ProfileFeatureDefinition feature = new ProfileFeatureDefinition();

            feature.featureType = FeatureType.BooleanValue;
            feature.featureKey  = featureKey;
            feature.name        = name;
            feature.value       = value;
            feature.tooltip     = tooltip;

            return(feature);
        }
Exemplo n.º 3
0
        public bool IsFeatureEnabled(string featureKey, bool recursive = true)
        {
            if (featureKey == null)
            {
                return(false);
            }

            // Load the definition for this feature so we can check for dependent features.
            ProfileFeatureDefinition feature = profileDefinition.GetFeatureDefinition(featureKey);

            if (feature == null)
            {
                return(false);
            }

            if (featureStatus.dict.ContainsKey(featureKey) == false || featureStatus[featureKey] == false)
            {
                return(false);
            }

            // Don't scan up the parent hiearchy any further.
            if (recursive == false)
            {
                return(true);
            }

            // Check the full dependency chain to check if this feature is disabled by a parent.
            ProfileFeatureDefinition childFeature = feature;
            ProfileFeatureDefinition parentFeature;

            while (childFeature != null)
            {
                parentFeature = profileDefinition.GetFeatureDefinition(childFeature.dependsOnFeature);
                if (parentFeature == null || parentFeature.featureKey == null)
                {
                    break;
                }

                if (featureStatus[parentFeature.featureKey] != childFeature.dependsOnValue)
                {
                    return(false);
                }

                childFeature = parentFeature;
            }

            return(true);
        }
Exemplo n.º 4
0
        // Feature that uses a shader keyword.
        public static ProfileFeatureDefinition CreateShaderFeature(
            string featureKey, string shaderKeyword, bool value, string name,
            string dependsOnFeature, bool dependsOnValue, string tooltip)
        {
            ProfileFeatureDefinition feature = new ProfileFeatureDefinition();

            feature.featureType      = FeatureType.ShaderKeyword;
            feature.featureKey       = featureKey;
            feature.shaderKeyword    = shaderKeyword;
            feature.name             = name;
            feature.value            = value;
            feature.tooltip          = tooltip;
            feature.dependsOnFeature = dependsOnFeature;
            feature.dependsOnValue   = dependsOnValue;

            return(feature);
        }
Exemplo n.º 5
0
        // Dropdown to select a mutually exclusive shader feature.
        public static ProfileFeatureDefinition CreateShaderFeatureDropdown(
            string[] featureKeys, string[] shaderKeywords, string[] labels, int selectedIndex, string name,
            string dependsOnFeature, bool dependsOnValue, string tooltip)
        {
            ProfileFeatureDefinition feature = new ProfileFeatureDefinition();

            feature.featureType           = FeatureType.ShaderKeywordDropdown;
            feature.featureKeys           = featureKeys;
            feature.shaderKeywords        = shaderKeywords;
            feature.dropdownLabels        = labels;
            feature.name                  = name;
            feature.dropdownSelectedIndex = selectedIndex;
            feature.tooltip               = tooltip;
            feature.dependsOnFeature      = dependsOnFeature;
            feature.dependsOnValue        = dependsOnValue;

            return(feature);
        }
Exemplo n.º 6
0
        private bool RenderFeatureCheckbox(ProfileFeatureDefinition def, bool keywordValue, out bool valueChanged)
        {
            EditorGUI.BeginChangeCheck();
            bool value = EditorGUILayout.Toggle(def.name, keywordValue);

            if (EditorGUI.EndChangeCheck())
            {
                // FIXME - Why doesn't the sky profile do this for us when we enable the feature?
                if (def.featureType == ProfileFeatureDefinition.FeatureType.ShaderKeyword)
                {
                    SetShaderKeyword(def.shaderKeyword, value);
                }
                m_Profile.SetFeatureEnabled(def.featureKey, value);
                valueChanged = true;
            }
            else
            {
                valueChanged = false;
            }

            return(value);
        }