示例#1
0
        private void AddNewCollisionMaskCacheEntry(RenderTexture texture, Terrain terrain, string fileName)
        {
            BakedMaskCacheEntry[] newArray = new BakedMaskCacheEntry[m_cacheEntries.Length + 1];
            int length2 = m_cacheEntries.Length;

            for (int i = 0; i < length2; i++)
            {
                newArray[i] = m_cacheEntries[i];
            }
            newArray[newArray.Length - 1] = new BakedMaskCacheEntry();
            WriteCacheEntry(newArray[newArray.Length - 1], texture, terrain, fileName);
            m_cacheEntries = newArray;
            //EditorUtility.SetDirty(this);
#if UNITY_EDITOR
            EditorUtility.SetDirty(GaiaSessionManager.GetSessionManager(false));
#endif
        }
示例#2
0
        private void WriteCacheEntry(BakedMaskCacheEntry entry, RenderTexture texture, Terrain terrain, string fileName)
        {
            //build the paths
            string assetPath = GaiaDirectories.GetTerrainCollisionDirectory(terrain) + "/" + fileName;
            string fullPath  = assetPath.Replace("Assets", Application.dataPath);

            //clear old texture
            if (entry.texture != null && entry.texture != Texture2D.whiteTexture)
            {
                UnityEngine.Object.DestroyImmediate(entry.texture);
                entry.texture = null;
            }
            //overwrite texture contents
            entry.texture = texture;

            //assign Paths & name
            entry.fileName  = fileName;
            entry.assetPath = assetPath;
            entry.fullPath  = fullPath;
        }