public void OnReset(object data = null) { lerpers = new TextureLerper[12]; texturePagePool = new TexturePagePool(); textureBuffers = new TextureBuffer[12]; externallyUpdatedTextures = new Texture2D[12]; for (int i = 0; i < 12; i++) { TextureProperties textureProperties = default(TextureProperties); textureProperties.textureFormat = TextureFormat.Alpha8; textureProperties.filterMode = FilterMode.Bilinear; textureProperties.blend = false; textureProperties.blendSpeed = 1f; TextureProperties item = textureProperties; for (int j = 0; j < this.textureProperties.Length; j++) { if (i == (int)this.textureProperties[j].simProperty) { item = this.textureProperties[j]; } } Property property = (Property)i; item.name = property.ToString(); if ((UnityEngine.Object)externallyUpdatedTextures[i] != (UnityEngine.Object)null) { UnityEngine.Object.Destroy(externallyUpdatedTextures[i]); externallyUpdatedTextures[i] = null; } Texture texture; if (item.updatedExternally) { externallyUpdatedTextures[i] = new Texture2D(Grid.WidthInCells, Grid.HeightInCells, TextureUtil.TextureFormatToGraphicsFormat(item.textureFormat), TextureCreationFlags.None); texture = externallyUpdatedTextures[i]; } else { TextureBuffer[] array = textureBuffers; int num = i; Property property2 = (Property)i; array[num] = new TextureBuffer(property2.ToString(), Grid.WidthInCells, Grid.HeightInCells, item.textureFormat, item.filterMode, texturePagePool); texture = textureBuffers[i].texture; } if (item.blend) { TextureLerper[] array2 = lerpers; int num2 = i; Texture target_texture = texture; Property property3 = (Property)i; array2[num2] = new TextureLerper(target_texture, property3.ToString(), texture.filterMode, item.textureFormat); lerpers[i].Speed = item.blendSpeed; } Shader.SetGlobalTexture(item.texturePropertyName = (texture.name = GetShaderPropertyName((Property)i)), texture); allTextureProperties.Add(item); } }
public TextureBuffer(string name, int width, int height, TextureFormat format, FilterMode filter_mode, TexturePagePool pool) { this.name = name; this.format = format; this.pool = pool; texture = new RenderTexture(width, height, 0, TextureUtil.GetRenderTextureFormat(format)); texture.name = name; texture.filterMode = filter_mode; texture.wrapMode = TextureWrapMode.Clamp; material = new Material(Shader.Find("Klei/TexturePage")); }