示例#1
0
        private void AssignAssets(StyleAssetPathBundle styleAssetPathBundle)
        {
            var topMaterial  = Resources.Load(styleAssetPathBundle.topMaterialPath, typeof(Material)) as Material;
            var sideMaterial = Resources.Load(styleAssetPathBundle.sideMaterialPath, typeof(Material)) as Material;

            var atlas   = Resources.Load(styleAssetPathBundle.atlasPath, typeof(AtlasInfo)) as AtlasInfo;
            var palette = Resources.Load(styleAssetPathBundle.palettePath, typeof(ScriptablePalette)) as ScriptablePalette;

//			Material[] tempMaterials = new Material[2];
//
//
//			for (int i = 0; i < materials.Length; i++)
//			{
//				if (materials[i].Materials[0] == null) continue;
//				tempMaterials[i] = materials[i].Materials[0];
//				materials[i].Materials[0] = null;
//			}

            materials[0].Materials[0] = new Material(topMaterial);
            materials[1].Materials[0] = new Material(sideMaterial);

//			for (int i = 0; i < materials.Length; i++)
//			{
//				if (tempMaterials[i] != null)
//				{
//					tempMaterials[i].Destroy();
//				}
//			}

            Resources.UnloadUnusedAssets();

            atlasInfo    = atlas;
            colorPalette = palette;
        }
示例#2
0
        public void SetDefaultAssets(UvMapType mapType = UvMapType.Atlas)
        {
            StyleAssetPathBundle styleAssetPathBundle = new StyleAssetPathBundle("Default", Constants.Path.MAP_FEATURE_STYLES_DEFAULT_STYLE_ASSETS);

            texturingType = mapType;
            AssignAssets(styleAssetPathBundle);
        }
        private void AssignAssets(StyleAssetPathBundle styleAssetPathBundle)
        {
            Material topMaterial  = Resources.Load(styleAssetPathBundle.topMaterialPath, typeof(Material)) as Material;
            Material sideMaterial = Resources.Load(styleAssetPathBundle.sideMaterialPath, typeof(Material)) as Material;

            AtlasInfo         atlas   = Resources.Load(styleAssetPathBundle.atlasPath, typeof(AtlasInfo)) as AtlasInfo;
            ScriptablePalette palette = Resources.Load(styleAssetPathBundle.palettePath, typeof(ScriptablePalette)) as ScriptablePalette;

            Material[] tempMaterials = new Material[2];

            for (int i = 0; i < materials.Length; i++)
            {
                if (materials[i].Materials[0] != null)
                {
                    tempMaterials[i]          = materials[i].Materials[0];
                    materials[i].Materials[0] = null;
                }
            }

            materials[0].Materials[0] = new Material(topMaterial);
            materials[1].Materials[0] = new Material(sideMaterial);

            for (int i = 0; i < materials.Length; i++)
            {
                if (tempMaterials[i] != null)
                {
                    tempMaterials[i].Destroy();
                }
            }

            Resources.UnloadUnusedAssets();

            atlasInfo    = atlas;
            colorPalette = palette;
        }
        /// <summary>
        /// Returns a new GeometryMaterialOptions object; called from VectorLayerVisualizer.SetProperties.
        /// </summary>
        /// <returns>The geometry material options.</returns>
        /// <param name="geometryMaterialOptions">Map feature style options.</param>
        ///

        public static GeometryMaterialOptions GetGeometryMaterialOptions(GeometryMaterialOptions geometryMaterialOptionsRef)
        {
            GeometryMaterialOptions geometryMaterialOptions;

            if (geometryMaterialOptionsRef.style == StyleTypes.Custom)
            {
                geometryMaterialOptions = geometryMaterialOptionsRef;
            }
            else
            {
                string styleName = geometryMaterialOptionsRef.style.ToString();

                string path = Path.Combine(Constants.Path.MAP_FEATURE_STYLES_SAMPLES, Path.Combine(styleName, Constants.Path.MAPBOX_STYLES_ASSETS_FOLDER));

                StyleAssetPathBundle styleAssetPathBundle = new StyleAssetPathBundle(styleName, path);

                geometryMaterialOptions = AssignAssets(new GeometryMaterialOptions(), styleAssetPathBundle);

                geometryMaterialOptions.style = geometryMaterialOptionsRef.style;

                if (geometryMaterialOptions.style == StyleTypes.Satellite)
                {
                    geometryMaterialOptions.texturingType = UvMapType.Tiled;
                }
                else if (geometryMaterialOptions.style == StyleTypes.Simple)
                {
                    geometryMaterialOptions.texturingType = UvMapType.AtlasWithColorPalette;
                }
                else
                {
                    geometryMaterialOptions.texturingType = UvMapType.Atlas;
                }
            }
            return(geometryMaterialOptions);
        }
        public static GeometryMaterialOptions GetDefaultAssets()
        {
            StyleAssetPathBundle    styleAssetPathBundle    = new StyleAssetPathBundle("Default", Constants.Path.MAP_FEATURE_STYLES_DEFAULT_STYLE_ASSETS);
            GeometryMaterialOptions geometryMaterialOptions = new GeometryMaterialOptions();

            geometryMaterialOptions.texturingType = UvMapType.Atlas;
            return(AssignAssets(geometryMaterialOptions, styleAssetPathBundle));
        }
示例#6
0
        private void AssignAssets(StyleAssetPathBundle styleAssetPathBundle)
        {
            Material topMaterial  = Resources.Load(styleAssetPathBundle.topMaterialPath, typeof(Material)) as Material;
            Material sideMaterial = Resources.Load(styleAssetPathBundle.sideMaterialPath, typeof(Material)) as Material;

            AtlasInfo         atlas   = Resources.Load(styleAssetPathBundle.atlasPath, typeof(AtlasInfo)) as AtlasInfo;
            ScriptablePalette palette = Resources.Load(styleAssetPathBundle.palettePath, typeof(ScriptablePalette)) as ScriptablePalette;

            materials[0].Materials[0] = new Material(topMaterial);
            materials[1].Materials[0] = new Material(sideMaterial);
            atlasInfo    = atlas;
            colorPalette = palette;
        }
示例#7
0
        /// <summary>
        /// Sets up default values for GeometryMaterial Options.
        /// If style is set to Custom, user defined values will be used.
        /// </summary>
        public void SetDefaultMaterialOptions()
        {
            var styleName = style.ToString();

            if (customStyleOptions == null)
            {
                customStyleOptions = new CustomStyleBundle();
                customStyleOptions.SetDefaultAssets();
            }
            if (style == StyleTypes.Custom)
            {
                //nothing to do. Use custom settings
            }
            else
            {
                var samplePaletteName = samplePalettes.ToString();

                var path = Path.Combine(Constants.Path.MAP_FEATURE_STYLES_SAMPLES, Path.Combine(styleName, Constants.Path.MAPBOX_STYLES_ASSETS_FOLDER));

                var styleAssetPathBundle = new StyleAssetPathBundle(styleName, path, samplePaletteName);

                AssignAssets(styleAssetPathBundle);
            }

            switch (style)
            {
            case StyleTypes.Light:
                var lightColor = materials[0].Materials[0].color;
                lightColor.a = lightStyleOpacity;
                materials[0].Materials[0].color = lightColor;

                lightColor   = materials[1].Materials[0].color;
                lightColor.a = lightStyleOpacity;
                materials[1].Materials[0].color = lightColor;
                break;

            case StyleTypes.Dark:
                var darkColor = materials[0].Materials[0].color;
                darkColor.a = darkStyleOpacity;
                materials[0].Materials[0].color = darkColor;

                darkColor   = materials[1].Materials[0].color;
                darkColor.a = darkStyleOpacity;
                materials[1].Materials[0].color = darkColor;
                break;

            case StyleTypes.Color:
                var color = colorStyleColor;
                materials[0].Materials[0].color = color;
                materials[1].Materials[0].color = color;
                break;

            default:
                break;
            }

            if (style == StyleTypes.Satellite)
            {
                texturingType = UvMapType.Tiled;
            }
            else
            {
                texturingType = (style != StyleTypes.Custom && style == StyleTypes.Simple) ? UvMapType.AtlasWithColorPalette : UvMapType.Atlas;
            }
        }
        /// <summary>
        /// Returns a new GeometryMaterialOptions object; called from VectorLayerVisualizer.SetProperties.
        /// </summary>
        /// <returns>The geometry material options.</returns>
        /// <param name="geometryMaterialOptions">Map feature style options.</param>
        ///

        public static GeometryMaterialOptions GetGeometryMaterialOptions(GeometryMaterialOptions geometryMaterialOptionsRef)
        {
            GeometryMaterialOptions geometryMaterialOptions;

            if (geometryMaterialOptionsRef.style == StyleTypes.Custom)
            {
                geometryMaterialOptions = geometryMaterialOptionsRef;
            }
            else
            {
                string styleName = geometryMaterialOptionsRef.style.ToString();

                string samplePaletteName = geometryMaterialOptionsRef.samplePalettes.ToString();

                string path = Path.Combine(Constants.Path.MAP_FEATURE_STYLES_SAMPLES, Path.Combine(styleName, Constants.Path.MAPBOX_STYLES_ASSETS_FOLDER));

                StyleAssetPathBundle styleAssetPathBundle = new StyleAssetPathBundle(styleName, path, samplePaletteName);

                geometryMaterialOptions = AssignAssets(new GeometryMaterialOptions(), styleAssetPathBundle);

                geometryMaterialOptions.style = geometryMaterialOptionsRef.style;

                geometryMaterialOptions.lightStyleOpacity = geometryMaterialOptionsRef.lightStyleOpacity;
                geometryMaterialOptions.darkStyleOpacity  = geometryMaterialOptionsRef.darkStyleOpacity;

                geometryMaterialOptions.colorStyleColor = geometryMaterialOptionsRef.colorStyleColor;

                switch (geometryMaterialOptions.style)
                {
                case StyleTypes.Light:
                    Color lightColor = geometryMaterialOptions.materials[0].Materials[0].color;
                    lightColor.a = geometryMaterialOptions.lightStyleOpacity;
                    geometryMaterialOptions.materials[0].Materials[0].color = lightColor;

                    lightColor   = geometryMaterialOptions.materials[1].Materials[0].color;
                    lightColor.a = geometryMaterialOptions.lightStyleOpacity;
                    geometryMaterialOptions.materials[1].Materials[0].color = lightColor;
                    break;

                case StyleTypes.Dark:
                    Color darkColor = geometryMaterialOptions.materials[0].Materials[0].color;
                    darkColor.a = geometryMaterialOptions.darkStyleOpacity;
                    geometryMaterialOptions.materials[0].Materials[0].color = darkColor;

                    darkColor   = geometryMaterialOptions.materials[1].Materials[0].color;
                    darkColor.a = geometryMaterialOptions.darkStyleOpacity;
                    geometryMaterialOptions.materials[1].Materials[0].color = darkColor;
                    break;

                case StyleTypes.Color:
                    Color color = geometryMaterialOptions.colorStyleColor;
                    geometryMaterialOptions.materials[0].Materials[0].color = color;
                    geometryMaterialOptions.materials[1].Materials[0].color = color;
                    break;

                default:
                    break;
                }

                if (geometryMaterialOptions.style == StyleTypes.Satellite)
                {
                    geometryMaterialOptions.texturingType = UvMapType.Tiled;
                }
                else if (geometryMaterialOptions.style == StyleTypes.Simple)
                {
                    geometryMaterialOptions.texturingType = UvMapType.AtlasWithColorPalette;
                }
                else
                {
                    geometryMaterialOptions.texturingType = UvMapType.Atlas;
                }
            }
            return(geometryMaterialOptions);
        }
        public static GeometryMaterialOptions AssignAssets(GeometryMaterialOptions geometryMaterialOptions, StyleAssetPathBundle styleAssetPathBundle)
        {
            Material topMaterial  = Resources.Load(styleAssetPathBundle.topMaterialPath, typeof(Material)) as Material;
            Material sideMaterial = Resources.Load(styleAssetPathBundle.sideMaterialPath, typeof(Material)) as Material;

            AtlasInfo         atlas   = Resources.Load(styleAssetPathBundle.atlasPath, typeof(AtlasInfo)) as AtlasInfo;
            ScriptablePalette palette = Resources.Load(styleAssetPathBundle.palettePath, typeof(ScriptablePalette)) as ScriptablePalette;

            geometryMaterialOptions.materials[0].Materials[0] = new Material(topMaterial);
            geometryMaterialOptions.materials[1].Materials[0] = new Material(sideMaterial);
            geometryMaterialOptions.atlasInfo    = atlas;
            geometryMaterialOptions.colorPalette = palette;

            return(geometryMaterialOptions);
        }