Example #1
0
        public static void BackUpScene()
        {
            CreateOptRoot();

            XOCp_OptimizerHandler xoh = XOGloble.Root.GetComponent <XOCp_OptimizerHandler>();

            xoh.olst.Clear();
            xoh.nlst.Clear();

            UnityEngine.Renderer[] rs = (UnityEngine.Renderer[])FindObjectsOfType(typeof(UnityEngine.Renderer));
            for (int i = 0; i < rs.Length; i++)
            {
                UnityEngine.Renderer r = rs[i];
                if (r is MeshRenderer)
                {
                    if (r.GetComponent <TextMesh>() != null)
                    {
                        continue;                         //don't add TextMeshes
                    }
                    if (r.GetComponent <XOCp_MarkIgnore>() != null)
                    {
                        continue;
                    }
                    if (r.gameObject.isStatic == true && r.gameObject.activeInHierarchy == true)
                    {
                        if (xoh != null)
                        {
                            xoh.olst.Add(r.gameObject);
                        }

                        if (XOMeshSplit.CanSplit(r.gameObject) == true)
                        {
                            XOMeshSplit.ExtractMaterialMeshes(r.gameObject);
                        }
                        else
                        {
                            UnityEngine.GameObject backobj = NewIterM(r.gameObject);
                            xoh.nlst.Add(backobj);
                            AddObjDic(r.gameObject, backobj);
                        }

                        xoh.bDisplayOrigin = false;
                        xoh.bDisplayNew    = true;
                        r.gameObject.SetActive(false);
                    }
                }
            }

            if (xoh != null)
            {
                xoh.CreateNodes();
            }
        }
Example #2
0
        public static void RealUpdateUV(UnityEngine.GameObject go, string matname)
        {
            //Debug.Log("RealUpdateUV matname=" + matname);

            if (Names2Coord.ContainsKey(matname) == true)
            {
                float x = float.Parse(getBetween(Names2Coord[matname], "x", "y"));
                float y = float.Parse(getBetween(Names2Coord[matname], "y", "w"));
                float w = float.Parse(getBetween(Names2Coord[matname], "w", "h"));
                float h = float.Parse(getBetween(Names2Coord[matname], "h", "end"));

                //Debug.Log("matname="+matname+"Names2Coord[matname]="+Names2Coord[matname]);

                MeshFilter lMeshFilter = go.GetComponent <MeshFilter>();
                if (lMeshFilter != null)
                {
                    Mesh lMesh = XOMeshSplit.CreateMesh(lMeshFilter.sharedMesh, 0);
                    UnityEngine.Vector2[] _uvOffset = lMesh.uv;

                    //Debug.Log("matname=" + matname + " Length=" + _uvOffset.Length);

                    for (int uv = 0; uv < _uvOffset.Length; uv++)
                    {
                        //Debug.Log("before[uv].x = " + _uvOffset[uv].x + " [uv].y = " + _uvOffset[uv].y);
                        // if(_uvOffset[uv].x>1.0f) _uvOffset[uv].x = 1.0f;
                        // if(_uvOffset[uv].x<0.0f) _uvOffset[uv].x = 0.0f;

                        // if(_uvOffset[uv].y>1.0f) _uvOffset[uv].y = 1.0f;
                        // if(_uvOffset[uv].y<0.0f) _uvOffset[uv].y = 0.0f;

                        _uvOffset[uv] = new UnityEngine.Vector2(_uvOffset[uv].x * (w) + (x), _uvOffset[uv].y * (h) + (y));
                        //Debug.Log("after[uv].x = " + _uvOffset[uv].x + " [uv].y = " + _uvOffset[uv].y);
                    }

                    lMesh.uv = _uvOffset;
                    lMeshFilter.sharedMesh = lMesh;
                }
            }

            // float x = float.Parse (getBetween (_textureCoords[_textureIndex],"x","y"));
            // float y = float.Parse (getBetween (_textureCoords[_textureIndex],"y","w"));
            // float w = float.Parse (getBetween (_textureCoords[_textureIndex],"w","h"));
            // float h = float.Parse (getBetween (_textureCoords[_textureIndex],"h","end"));


            // Mesh _meshCopy = new Mesh ();

            // foreach(var property in typeof(Mesh).GetProperties()){
            //     if(property.GetSetMethod() != null && property.GetGetMethod() != null){
            //         property.SetValue(_meshCopy, property.GetValue(_goMesh[_meshIndex], null), null);
            //     }
            // }
            // UnityEngine.Vector2[] _uvOffset = _meshCopy.uv;

            // for(int uv = 0; uv < _uvOffset.Length;uv++){
            //     _uvOffset[uv] = new UnityEngine.Vector2 (_uvOffset[uv].x * (w) + (x),_uvOffset[uv].y *(h)+(y));
            // }

            // _meshCopy.uv = _uvOffset;
            // _gos[_meshIndex].sharedMesh =_meshCopy;
        }