/// <summary>
        /// Create an LBLayerFilter for Stencil Layer using the LBStencil instance and the name of the layer
        /// </summary>
        /// <param name="lbStencil"></param>
        /// <param name="layerName"></param>
        /// <param name="showErrors"></param>
        /// <returns></returns>
        public static LBLayerFilter CreateLayerFilter(LBStencil lbStencil, string layerName, bool showErrors)
        {
            LBLayerFilter lbLayerFilter = null;

            if (lbStencil == null)
            {
                if (showErrors)
                {
                    Debug.LogWarning("LBLayerFilter.CreateLayerFilter - stencil is null");
                }
            }
            else if (string.IsNullOrEmpty(layerName))
            {
                if (showErrors)
                {
                    Debug.LogWarning("LBLayerFilter.CreateLayerFilter - layerName is an empty string");
                }
            }
            else
            {
                lbLayerFilter = new LBLayerFilter();
                if (lbLayerFilter == null)
                {
                    if (showErrors)
                    {
                        Debug.LogWarning("LBLayerFilter.CreateLayerFilter - could not create LBLayerFilter for " + lbStencil.stencilName + "." + layerName);
                    }
                }
                else
                {
                    lbLayerFilter.type          = LBLayerFilter.LayerFilterType.StencilLayer;
                    lbLayerFilter.lbStencilGUID = lbStencil.GUID;

                    // Find the new stencil layer
                    LBStencilLayer lbStencilLayer = lbStencil.GetStencilLayerByName(layerName);
                    if (lbStencilLayer != null)
                    {
                        lbLayerFilter.lbStencilLayerGUID = lbStencilLayer.GUID;
                    }
                    else
                    {
                        lbLayerFilter = null;
                    }
                }
            }

            return(lbLayerFilter);
        }
Пример #2
0
        /// <summary>
        /// Create a LBTemplateStencil from a LBStencil
        /// </summary>
        /// <param name="lbStencil"></param>
        public LBTemplateStencil(LBStencil lbStencil)
        {
            this.GUID        = lbStencil.GUID;
            this.stencilName = lbStencil.stencilName;

            this.stencilLayerList = new List <LBStencilLayer>();

            if (lbStencil.stencilLayerList != null)
            {
                LBStencilLayer templbStencilLayer = null;

                // Add new Stencil Layers to the LBTemplateStencil without the USHORT layerArray and renderTexture
                foreach (LBStencilLayer lbStencilLayer in lbStencil.stencilLayerList)
                {
                    // Copy the StencilLayer with the compressTexture
                    templbStencilLayer = new LBStencilLayer(lbStencilLayer, true, false, false);

                    if (templbStencilLayer != null)
                    {
                        // Copy the compressTexture data into the USHORT so that we can serialise it
                        templbStencilLayer.AllocLayerArrayX();
                        templbStencilLayer.UnCompressToUShortX();
                        // Texture2D class isn't saved with the serialised so no need to keep it.
                        templbStencilLayer.compressedTexture = null;
                    }

                    if (templbStencilLayer != null)
                    {
                        this.stencilLayerList.Add(templbStencilLayer);
                    }
                }
            }

            this.showStencilSettings = lbStencil.showStencilSettings;
            this.brushSize           = lbStencil.brushSize;
            this.smoothStrength      = lbStencil.smoothStrength;
        }