Esempio n. 1
0
 public void ConstructObject(PropInfo sourceProp, int id, Texture2D customTex = null)
 {
     this._baseProp          = sourceProp;
     this.id                 = id;
     this.basePrefabName     = sourceProp.name;
     this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt();
     this.baseInfoType       = "PROP";
     this.renderDistance     = ProceduralObjectsMod.PropRenderDistance.value;
     // this.flipFaces = false;
     this.tilingFactor = 8;
     m_position        = ToolsModifierControl.cameraController.m_currentPosition;
     m_rotation        = Quaternion.identity;
     // Mesh mesh = sourceProp.m_mesh.InstantiateMesh();
     // meshStatus = 1;
     m_mesh      = sourceProp.m_mesh.InstantiateMesh();
     allVertices = sourceProp.m_mesh.vertices;
     m_material  = GameObject.Instantiate(sourceProp.m_material);
     if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal")
     {
         m_material.ApplyPloppableColor();
     }
     m_visibility         = ProceduralObjectVisibility.Always;
     historyEditionBuffer = new HistoryBuffer(this);
     if (customTex != null)
     {
         m_material.mainTexture = customTex as Texture;
         customTexture          = customTex;
         disableRecalculation   = false;
     }
 }
 public void ConstructObject(PropInfo sourceProp, int id, Texture customTex = null, bool skipDecalShrink = false)
 {
     this._baseProp          = sourceProp;
     this.id                 = id;
     this.basePrefabName     = sourceProp.name;
     this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt();
     this.baseInfoType       = "PROP";
     // this.flipFaces = false;
     this.tilingFactor = 8;
     m_position        = ToolsModifierControl.cameraController.m_currentPosition;
     m_rotation        = Quaternion.identity;
     // Mesh mesh = sourceProp.m_mesh.InstantiateMesh();
     // meshStatus = 1;
     m_material = GameObject.Instantiate(sourceProp.m_material);
     if (sourceProp.m_isDecal && ProceduralObjectsMod.AutoResizeDecals.value && !skipDecalShrink)
     {
         m_mesh = sourceProp.m_mesh.InstantiateMesh();
         m_mesh.SetVertices(m_mesh.vertices.ResizeDecal());
         vertices   = Vertex.CreateVertexList(this);
         meshStatus = 2;
     }
     else
     {
         m_mesh     = sourceProp.m_mesh;
         vertices   = Vertex.CreateVertexList(sourceProp);
         meshStatus = 1;
         RecalculateBoundsNormalsExtras(1);
     }
     this.renderDistance  = RenderOptions.instance.CalculateRenderDistance(this, true);
     m_visibility         = ProceduralObjectVisibility.Always;
     historyEditionBuffer = new HistoryBuffer(this);
     normalsRecalcMode    = NormalsRecalculation.None;
     if (_baseProp.m_useColorVariations && ProceduralObjectsMod.UseColorVariation.value)
     {
         m_color          = _baseProp.GetColor(ref Singleton <SimulationManager> .instance.m_randomizer);
         m_material.color = m_color;
     }
     else
     {
         if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal")
         {
             m_color = m_material.ApplyPloppableColor();
         }
         else
         {
             m_color = Color.white;
         }
     }
     if (customTex != null)
     {
         m_material.mainTexture = customTex as Texture;
         customTexture          = customTex;
         disableRecalculation   = false;
     }
     m_modules = new List <POModule>();
 }
 public ProceduralObject(CacheProceduralObject sourceCacheObj, int id, Vector3 position, LayerManager layerManager)
 {
     if (sourceCacheObj.baseInfoType == "PROP")
     {
         PropInfo sourceProp = sourceCacheObj._baseProp;
         if (sourceCacheObj._baseProp == null)
         {
             sourceProp = Resources.FindObjectsOfTypeAll <PropInfo>().FirstOrDefault(info => info.name == sourceCacheObj.basePrefabName);
         }
         this._baseProp          = sourceProp;
         this.id                 = id;
         this.basePrefabName     = sourceCacheObj.basePrefabName;
         this.baseInfoType       = "PROP";
         this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt();
         m_material              = GameObject.Instantiate(sourceProp.m_material);
         if (sourceCacheObj.meshStatus == 2)
         {
             m_mesh = sourceProp.m_mesh.InstantiateMesh();
             m_mesh.SetVertices(new List <Vector3>(sourceCacheObj.allVertices));
             vertices   = Vertex.CreateVertexList(this);
             meshStatus = 2;
         }
         else
         {
             meshStatus = 1;
             m_mesh     = sourceProp.m_mesh;
             vertices   = Vertex.CreateVertexList(sourceProp);
         }
         if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal")
         {
             m_color = m_material.ApplyPloppableColor();
         }
     }
     else if (sourceCacheObj.baseInfoType == "BUILDING")// building
     {
         BuildingInfo sourceBuilding = sourceCacheObj._baseBuilding;
         if (sourceCacheObj._baseBuilding == null)
         {
             sourceBuilding = Resources.FindObjectsOfTypeAll <BuildingInfo>().FirstOrDefault(info => info.name == sourceCacheObj.basePrefabName);
         }
         this._baseBuilding      = sourceBuilding;
         this.id                 = id;
         this.basePrefabName     = sourceCacheObj.basePrefabName;
         this.baseInfoType       = "BUILDING";
         this.isPloppableAsphalt = false;
         m_material              = GameObject.Instantiate(sourceBuilding.m_material);
         m_mesh     = sourceBuilding.m_mesh.InstantiateMesh();
         meshStatus = 2;
         m_mesh.SetVertices(new List <Vector3>(sourceCacheObj.allVertices));
         vertices        = Vertex.CreateVertexList(this);
         m_mesh.colors   = new Color[] { };
         m_mesh.colors32 = new Color32[] { };
     }
     if (sourceCacheObj.customTexture != null)
     {
         m_material.mainTexture = sourceCacheObj.customTexture as Texture;
         customTexture          = sourceCacheObj.customTexture;
     }
     m_visibility         = sourceCacheObj.visibility;
     historyEditionBuffer = new HistoryBuffer(this);
     if (sourceCacheObj.textParam != null)
     {
         m_textParameters = TextParameters.Clone(sourceCacheObj.textParam, false);
         // m_textParameters.SetFonts();
         var originalTex = new Texture2D(m_material.mainTexture.width, m_material.mainTexture.height, TextureFormat.RGBA32, false);
         originalTex.SetPixels(((Texture2D)m_material.mainTexture).GetPixels());
         originalTex.Apply();
         m_material.mainTexture = m_textParameters.ApplyParameters(originalTex);
     }
     else
     {
         m_textParameters = null;
     }
     if (sourceCacheObj.layer != null)
     {
         if (layerManager.m_layers.Contains(sourceCacheObj.layer))
         {
             layer = sourceCacheObj.layer;
         }
     }
     m_color                 = sourceCacheObj.m_color;
     m_material.color        = m_color;
     this.flipFaces          = sourceCacheObj.flipFaces;
     this.disableCastShadows = sourceCacheObj.disableCastShadows;
     if (this.flipFaces)
     {
         VertexUtils.flipFaces(this);
     }
     renderDistance   = sourceCacheObj.renderDistance;
     renderDistLocked = sourceCacheObj.renderDistLocked;
     MaterialOptions.FixDecalRenderDist(this);
     m_position           = position;
     m_rotation           = sourceCacheObj.m_rotation;
     disableRecalculation = sourceCacheObj.disableRecalculation;
     normalsRecalcMode    = sourceCacheObj.normalsRecalculation;
     this.tilingFactor    = sourceCacheObj.tilingFactor;
     if (sourceCacheObj.modules != null)
     {
         m_modules = new List <POModule>();
         foreach (var m in sourceCacheObj.modules)
         {
             POModule clone;
             try { clone = m.Clone(); }
             catch (Exception e)
             {
                 Debug.LogError("[ProceduralObjects] Error inside module Clone() method!\n" + e);
                 continue;
             }
             ModuleManager.instance.modules.Add(clone);
             if (clone.enabled)
             {
                 ModuleManager.instance.enabledModules.Add(clone);
             }
             clone.parentObject = this;
             try { clone.OnModuleCreated(ProceduralObjectsLogic.instance); }
             catch (Exception e) { Debug.LogError("[ProceduralObjects] Error inside module OnModuleCreated() method!\n" + e); }
             m_modules.Add(clone);
         }
     }
 }
        public ProceduralObject(ProceduralObjectContainer container, LayerManager layerManager, PropInfo[] props, BuildingInfo[] buildings)
        {
            if (container.objectType == "PROP")
            {
                PropInfo sourceProp = props.FirstOrDefault(info => info.name == container.basePrefabName);
                this._baseProp          = sourceProp;
                this.id                 = container.id;
                this.basePrefabName     = container.basePrefabName;
                this.baseInfoType       = "PROP";
                this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt();
                m_position              = container.position.ToVector3();
                m_rotation              = container.rotation.ToQuaternion();
                m_material              = GameObject.Instantiate(sourceProp.m_material); // overkil ??
                if (container.meshStatus == 0 && container.vertices != null)
                {
                    // CHECK FOR MESH REPETITION
                    if (ProceduralUtils.CheckMeshEquivalence(container.vertices, sourceProp.m_mesh.vertices))
                    {
                        meshStatus = 1;
                        m_mesh     = sourceProp.m_mesh;
                        vertices   = Vertex.CreateVertexList(sourceProp);
                    }
                    else
                    {
                        meshStatus = 2;
                        m_mesh     = sourceProp.m_mesh.InstantiateMesh();
                        var vert = SerializableVector3.ToStandardVector3Array(container.vertices);
                        if (container.scale != 0)
                        {
                            for (int i = 0; i < vert.Count(); i++)
                            {
                                vert[i] = new Vector3(vert[i].x * container.scale, vert[i].y * container.scale, vert[i].z * container.scale);
                            }
                        }
                        m_mesh.SetVertices(new List <Vector3>(vert));
                        vertices = Vertex.CreateVertexList(this);
                    }
                }
                else if (container.meshStatus == 1)
                {
                    meshStatus = 1;
                    m_mesh     = sourceProp.m_mesh;
                    vertices   = Vertex.CreateVertexList(sourceProp);
                }
                else // meshstatus2
                {
                    meshStatus = 2;
                    m_mesh     = sourceProp.m_mesh.InstantiateMesh();
                    if (container.serializedMeshData != null)
                    {
                        container.serializedMeshData.ApplyDataToObject(this);
                    }
                    else if (container.vertices != null)
                    {
                        var vert = SerializableVector3.ToStandardVector3Array(container.vertices);
                        if (container.scale != 0)
                        {
                            for (int i = 0; i < vert.Count(); i++)
                            {
                                vert[i] = new Vector3(vert[i].x * container.scale, vert[i].y * container.scale, vert[i].z * container.scale);
                            }
                        }
                        m_mesh.SetVertices(new List <Vector3>(vert));
                    }
                    else
                    {
                        throw new Exception("[ProceduralObjects] Loading failure : Missing mesh data !");
                    }
                    vertices = Vertex.CreateVertexList(this);
                }
                if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal")
                {
                    m_color = m_material.ApplyPloppableColor();
                }
                if (container.hasCustomTexture && TextureManager.instance != null)
                {
                    var customTex = TextureManager.instance.FindTexture(container.customTextureName);
                    m_material.mainTexture = customTex as Texture;
                    customTexture          = customTex;
                }
            }
            else if (container.objectType == "BUILDING")// building
            {
                BuildingInfo sourceProp = buildings.FirstOrDefault(info => info.name == container.basePrefabName);
                this._baseBuilding      = sourceProp;
                this.id                 = container.id;
                this.basePrefabName     = container.basePrefabName;
                this.baseInfoType       = "BUILDING";
                this.isPloppableAsphalt = false;
                m_position              = container.position.ToVector3();
                m_rotation              = container.rotation.ToQuaternion();
                meshStatus              = 2;
                m_material              = GameObject.Instantiate(sourceProp.m_material); // overkill ??
                m_mesh = sourceProp.m_mesh.InstantiateMesh();
                if (container.serializedMeshData != null)
                {
                    container.serializedMeshData.ApplyDataToObject(this);
                }
                else if (container.vertices != null)
                {
                    var vert = SerializableVector3.ToStandardVector3Array(container.vertices);
                    if (container.scale != 0)
                    {
                        for (int i = 0; i < vert.Count(); i++)
                        {
                            vert[i] = new Vector3(vert[i].x * container.scale, vert[i].y * container.scale, vert[i].z * container.scale);
                        }
                    }
                    m_mesh.SetVertices(new List <Vector3>(vert));
                }
                else
                {
                    throw new Exception("[ProceduralObjects] Loading failure : Missing mesh data !");
                }
                vertices        = Vertex.CreateVertexList(this);
                m_mesh.colors   = new Color[] { };
                m_mesh.colors32 = new Color32[] { };

                if (container.hasCustomTexture && TextureManager.instance != null)
                {
                    var customTex = TextureManager.instance.FindTexture(container.customTextureName);
                    m_material.mainTexture = customTex as Texture;
                    customTexture          = customTex;
                }
            }
            m_visibility   = container.visibility;
            renderDistance = container.renderDistance;
            MaterialOptions.FixDecalRenderDist(this);
            renderDistLocked = container.renderDistLocked;
            if (container.textParam != null)
            {
                m_textParameters = TextParameters.Clone(container.textParam, true);
                for (int i = 0; i < m_textParameters.Count(); i++)
                {
                    if (m_textParameters[i].m_fontColor == null)
                    {
                        if (m_textParameters[i].serializableColor != null)
                        {
                            m_textParameters[i].m_fontColor = m_textParameters[i].serializableColor.ToColor();
                        }
                        else
                        {
                            m_textParameters[i].m_fontColor = Color.white;
                        }
                    }
                }
                //  m_textParameters.SetFonts();
                var originalTex = new Texture2D(m_material.mainTexture.width, m_material.mainTexture.height, TextureFormat.RGBA32, false);
                originalTex.SetPixels(((Texture2D)m_material.mainTexture).GetPixels());
                originalTex.Apply();
                m_material.mainTexture = m_textParameters.ApplyParameters(originalTex) as Texture;
            }
            else
            {
                m_textParameters = null;
            }
            if (container.belongsToGroup)
            {
                if (container.groupRootId == -1)
                {
                    isRootOfGroup    = true;
                    _groupRootIdData = -1;
                }
                else
                {
                    _groupRootIdData = container.groupRootId;
                    isRootOfGroup    = false;
                }
            }
            else
            {
                _groupRootIdData = -2;
                group            = null;
                isRootOfGroup    = false;
            }

            disableRecalculation    = container.disableRecalculation;
            this.normalsRecalcMode  = container.normalsRecalculation;
            this.flipFaces          = container.flipFaces;
            this.disableCastShadows = container.disableCastShadows;
            if (this.flipFaces)
            {
                VertexUtils.flipFaces(this);
            }
            historyEditionBuffer = new HistoryBuffer(this);

            if (container.color == null)
            {
                if (!(m_mesh.name == "ploppableasphalt-prop" || m_mesh.name == "ploppableasphalt-decal"))
                {
                    m_color = Color.white;
                }
            }
            else
            {
                m_color          = container.color;
                m_material.color = m_color;
            }

            if (container.layerId != 0)
            {
                if (layerManager.m_layers.Any(l => l.m_id == container.layerId))
                {
                    layer = layerManager.m_layers.Single(l => l.m_id == container.layerId);
                }
                else
                {
                    Debug.LogError("[ProceduralObjects] Layer of an object not found !");
                }
            }
            else
            {
                layer = null;
            }
            if (container.tilingFactor == 0)
            {
                this.tilingFactor = 8;
            }
            else
            {
                this.tilingFactor = container.tilingFactor;
            }

            m_modules = ModuleManager.LoadModulesFromData(container.modulesData, true, this);
        }
Esempio n. 5
0
 public ProceduralObject(CacheProceduralObject sourceCacheObj, int id, Vector3 position)
 {
     if (sourceCacheObj.baseInfoType == "PROP")
     {
         PropInfo sourceProp = sourceCacheObj._baseProp;
         if (sourceCacheObj._baseProp == null)
         {
             sourceProp = Resources.FindObjectsOfTypeAll <PropInfo>().FirstOrDefault(info => info.name == sourceCacheObj.basePrefabName);
         }
         this._baseProp          = sourceProp;
         this.id                 = id;
         this.basePrefabName     = sourceCacheObj.basePrefabName;
         this.baseInfoType       = "PROP";
         this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt();
         renderDistance          = sourceCacheObj.renderDistance;
         m_position              = position;
         m_rotation              = sourceCacheObj.m_rotation;
         m_mesh      = sourceProp.m_mesh.InstantiateMesh();
         allVertices = sourceCacheObj.allVertices;
         m_mesh.SetVertices(new List <Vector3>(allVertices));
         m_material = GameObject.Instantiate(sourceProp.m_material);
         if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal")
         {
             m_material.ApplyPloppableColor();
         }
     }
     else if (sourceCacheObj.baseInfoType == "BUILDING")// building
     {
         BuildingInfo sourceBuilding = sourceCacheObj._baseBuilding;
         if (sourceCacheObj._baseBuilding == null)
         {
             sourceBuilding = Resources.FindObjectsOfTypeAll <BuildingInfo>().FirstOrDefault(info => info.name == sourceCacheObj.basePrefabName);
         }
         this._baseBuilding      = sourceBuilding;
         this.id                 = id;
         this.basePrefabName     = sourceCacheObj.basePrefabName;
         this.baseInfoType       = "BUILDING";
         this.isPloppableAsphalt = false;
         renderDistance          = sourceCacheObj.renderDistance;
         m_position              = position;
         m_rotation              = sourceCacheObj.m_rotation;
         m_mesh      = sourceBuilding.m_mesh.InstantiateMesh();
         allVertices = sourceCacheObj.allVertices;
         m_mesh.SetVertices(new List <Vector3>(allVertices));
         m_mesh.colors   = new Color[] { };
         m_mesh.colors32 = new Color32[] { };
         m_material      = GameObject.Instantiate(sourceBuilding.m_material);
     }
     if (sourceCacheObj.customTexture != null)
     {
         m_material.mainTexture = sourceCacheObj.customTexture as Texture;
         customTexture          = sourceCacheObj.customTexture;
     }
     m_visibility         = sourceCacheObj.visibility;
     historyEditionBuffer = new HistoryBuffer(this);
     if (sourceCacheObj.textParam != null)
     {
         m_textParameters = TextParameters.Clone(sourceCacheObj.textParam, false);
         // m_textParameters.SetFonts();
         var originalTex = new Texture2D(m_material.mainTexture.width, m_material.mainTexture.height, TextureFormat.RGBA32, false);
         originalTex.SetPixels(((Texture2D)m_material.mainTexture).GetPixels());
         originalTex.Apply();
         m_material.mainTexture = m_textParameters.ApplyParameters(originalTex);
     }
     else
     {
         m_textParameters = null;
     }
     // this.flipFaces = sourceCacheObj.flipFaces;
     // if (this.flipFaces)
     //      VertexUtils.flipFaces(this);
     disableRecalculation = sourceCacheObj.disableRecalculation;
     this.tilingFactor    = sourceCacheObj.tilingFactor;
 }
Esempio n. 6
0
        public ProceduralObject(ProceduralObjectContainer container, List <Texture2D> textures, LayerManager layerManager)
        {
            if (container.objectType == "PROP")
            {
                PropInfo sourceProp = Resources.FindObjectsOfTypeAll <PropInfo>().FirstOrDefault(info => info.name == container.basePrefabName);
                this._baseProp          = sourceProp;
                this.id                 = container.id;
                this.basePrefabName     = container.basePrefabName;
                this.baseInfoType       = "PROP";
                this.isPloppableAsphalt = sourceProp.IsPloppableAsphalt();
                renderDistance          = container.renderDistance;
                m_position              = container.position.ToVector3();
                m_rotation              = container.rotation.ToQuaternion();

                /*
                 * if (container.meshStatus == 0)
                 * {
                 * // CHECK FOR MESH REPETITION
                 * if (ProceduralUtils.CheckMeshEquivalence(container.vertices, sourceProp.m_mesh.vertices))
                 * {
                 *  meshStatus = 1;
                 *  m_mesh = sourceProp.m_mesh;
                 *  allVertices = sourceProp.m_mesh.vertices;
                 * }
                 * else
                 * {
                 *  meshStatus = 2;
                 * m_mesh = sourceProp.m_mesh.InstantiateMesh();
                 * allVertices = SerializableVector3.ToStandardVector3Array(container.vertices);
                 * if (container.scale != 0)
                 * {
                 *  for (int i = 0; i < allVertices.Count(); i++)
                 *  {
                 *      allVertices[i] = new Vector3(allVertices[i].x * container.scale, allVertices[i].y * container.scale, allVertices[i].z * container.scale);
                 *  }
                 * }
                 * m_mesh.SetVertices(new List<Vector3>(allVertices));
                 * // }
                 * }
                 * else if (container.meshStatus == 1)
                 * {
                 * m_mesh = sourceProp.m_mesh;
                 * allVertices = sourceProp.m_mesh.vertices;
                 * }
                 * else if (container.meshStatus == 2)
                 * { */
                m_mesh      = sourceProp.m_mesh.InstantiateMesh();
                allVertices = SerializableVector3.ToStandardVector3Array(container.vertices);
                if (container.scale != 0)
                {
                    for (int i = 0; i < allVertices.Count(); i++)
                    {
                        allVertices[i] = new Vector3(allVertices[i].x * container.scale, allVertices[i].y * container.scale, allVertices[i].z * container.scale);
                    }
                }
                m_mesh.SetVertices(new List <Vector3>(allVertices));
                // }
                m_material = GameObject.Instantiate(sourceProp.m_material); // overkil ??
                if (sourceProp.m_mesh.name == "ploppableasphalt-prop" || sourceProp.m_mesh.name == "ploppableasphalt-decal")
                {
                    m_material.ApplyPloppableColor();
                }
                if (container.hasCustomTexture && textures != null)
                {
                    if (!textures.Any(tex => tex.name == container.customTextureName))
                    {
                        Debug.LogError("[ProceduralObjects] An object was found with a texture that doesn't exist anymore with the name " + container.customTextureName + ", therefore loading the default object texture");
                    }
                    else
                    {
                        var customTex = textures.FirstOrDefault(tex => tex.name == container.customTextureName);
                        m_material.mainTexture = customTex as Texture;
                        customTexture          = customTex;
                    }
                }
            }
            else if (container.objectType == "BUILDING")// building
            {
                BuildingInfo sourceProp = Resources.FindObjectsOfTypeAll <BuildingInfo>().FirstOrDefault(info => info.name == container.basePrefabName);
                this._baseBuilding      = sourceProp;
                this.id                 = container.id;
                this.basePrefabName     = container.basePrefabName;
                this.baseInfoType       = "BUILDING";
                this.isPloppableAsphalt = false;
                renderDistance          = container.renderDistance;
                m_position              = container.position.ToVector3();
                m_rotation              = container.rotation.ToQuaternion();

                /*
                 * if (container.meshStatus == 0)
                 * {
                 * // CHECK FOR MESH REPETITION
                 * if (ProceduralUtils.CheckMeshEquivalence(container.vertices, sourceProp.m_mesh.vertices))
                 * {
                 *  meshStatus = 1;
                 *  m_mesh = sourceProp.m_mesh;
                 *  allVertices = sourceProp.m_mesh.vertices;
                 * }
                 * else
                 * {
                 *  meshStatus = 2;
                 * m_mesh = sourceProp.m_mesh.InstantiateMesh();
                 * allVertices = SerializableVector3.ToStandardVector3Array(container.vertices);
                 * if (container.scale != 0)
                 * {
                 *  for (int i = 0; i < allVertices.Count(); i++)
                 *  {
                 *      allVertices[i] = new Vector3(allVertices[i].x * container.scale, allVertices[i].y * container.scale, allVertices[i].z * container.scale);
                 *  }
                 * }
                 * m_mesh.SetVertices(new List<Vector3>(allVertices));
                 * //  m_mesh.colors = new Color[] { };
                 * //  m_mesh.colors32 = new Color32[] { };}
                 * // }
                 * }
                 * else if (container.meshStatus == 1)
                 * {
                 * m_mesh = sourceProp.m_mesh;
                 * allVertices = sourceProp.m_mesh.vertices;
                 * }
                 * else if (container.meshStatus == 2)
                 * {*/
                m_mesh      = sourceProp.m_mesh.InstantiateMesh();
                allVertices = SerializableVector3.ToStandardVector3Array(container.vertices);
                if (container.scale != 0)
                {
                    for (int i = 0; i < allVertices.Count(); i++)
                    {
                        allVertices[i] = new Vector3(allVertices[i].x * container.scale, allVertices[i].y * container.scale, allVertices[i].z * container.scale);
                    }
                }
                m_mesh.SetVertices(new List <Vector3>(allVertices));
                m_mesh.colors   = new Color[] { };
                m_mesh.colors32 = new Color32[] { };
                // }

                m_material = GameObject.Instantiate(sourceProp.m_material); // overkill ??
                if (container.hasCustomTexture && textures != null)
                {
                    if (!textures.Any(tex => tex.name == container.customTextureName))
                    {
                        Debug.LogError("[ProceduralObjects] An object was found with a texture that doesn't exist anymore at the specified path " + container.hasCustomTexture + ", therefore loading the default object texture");
                    }
                    else
                    {
                        var customTex = textures.FirstOrDefault(tex => tex.name == container.customTextureName);
                        m_material.mainTexture = customTex as Texture;
                        customTexture          = customTex;
                    }
                }
            }
            m_visibility = container.visibility;
            if (container.textParam != null)
            {
                m_textParameters = TextParameters.Clone(container.textParam, true);
                for (int i = 0; i < m_textParameters.Count(); i++)
                {
                    if (m_textParameters[i].m_fontColor == null)
                    {
                        if (m_textParameters[i].serializableColor != null)
                        {
                            m_textParameters[i].m_fontColor = m_textParameters[i].serializableColor.ToColor();
                        }
                        else
                        {
                            m_textParameters[i].m_fontColor = Color.white;
                        }
                    }
                }
                //  m_textParameters.SetFonts();
                var originalTex = new Texture2D(m_material.mainTexture.width, m_material.mainTexture.height, TextureFormat.RGBA32, false);
                originalTex.SetPixels(((Texture2D)m_material.mainTexture).GetPixels());
                originalTex.Apply();
                m_material.mainTexture = m_textParameters.ApplyParameters(originalTex) as Texture;
            }
            else
            {
                m_textParameters = null;
            }
            disableRecalculation = container.disableRecalculation;
            //  this.flipFaces = container.flipFaces;
            //  if (this.flipFaces)
            //      VertexUtils.flipFaces(this);
            historyEditionBuffer = new HistoryBuffer(this);
            if (container.layerId != 0)
            {
                if (layerManager.m_layers.Any(l => l.m_id == container.layerId))
                {
                    layer = layerManager.m_layers.Single(l => l.m_id == container.layerId);
                }
                else
                {
                    Debug.LogError("[ProceduralObjects] Layer of an object not found !");
                }
            }
            else
            {
                layer = null;
            }
            if (container.tilingFactor == 0)
            {
                this.tilingFactor = 8;
            }
            else
            {
                this.tilingFactor = container.tilingFactor;
            }
        }