/// <summary> /// テクスチャファイルを設定 /// </summary> /// <param name="graphic">グラフィック情報</param> public void LoadFile(AdvGraphicInfo graphic) { this.GraphicInfo = graphic; this.Loader.LoadGraphic( graphic, () => { switch (graphic.FileType) { case AdvGraphicInfo.FileType2D: case "": RawImage rawImage = ChangeGraphicComponent <RawImage>(); rawImage.texture = graphic.File.Texture; InitSize(new Vector2(rawImage.texture.width, rawImage.texture.height)); break; case AdvGraphicInfo.FileTypeDicing: DicingImage dicingImage = ChangeGraphicComponent <DicingImage>(); dicingImage.DicingData = graphic.File.UnityObject as DicingTextures; string pattern = graphic.SubFileName; dicingImage.ChangePattern(pattern); InitSize(new Vector2(dicingImage.PatternData.Width, dicingImage.PatternData.Height)); break; default: Debug.LogError(graphic.FileType + " is not support "); break; } OnLoadEnd.Invoke(); }); }
public override void RebuildVertex(VertexHelper vh) { if (fadePatternData == null) { return; } vh.Clear(); var r = Target.GetPixelAdjustedRect(); var color32 = Target.color; DicingImage targetDicing = Target as DicingImage; float scaleX = r.width / fadePatternData.Width; float scaleY = r.height / fadePatternData.Height; int index = 0; List <DicingTextureData.QuadVerts> defaultVerts = targetDicing.GetVerts(targetDicing.PatternData); List <DicingTextureData.QuadVerts> fadeVerts = targetDicing.GetVerts(fadePatternData); int count = defaultVerts.Count; if (count != fadeVerts.Count) { count = Mathf.Min(count, fadeVerts.Count); Debug.LogError(string.Format("Not equal texture size {0} and {1}", targetDicing.PatternData.Name, fadePatternData.Name)); } for (int i = 0; i < count; ++i) { var vert0 = defaultVerts[i]; var vert1 = fadeVerts[i]; if (targetDicing.SkipTransParentCell && vert0.isAllTransparent && vert1.isAllTransparent) { continue; } Vector4 v = new Vector4( r.x + scaleX * vert0.v.x, r.y + scaleY * vert0.v.y, r.x + scaleX * vert0.v.z, r.y + scaleY * vert0.v.w ); Rect uvRect0 = vert0.uvRect; Rect uvRect1 = vert1.uvRect; vh.AddVert(new Vector3(v.x, v.y), color32, new Vector2(uvRect0.xMin, uvRect0.yMin), new Vector2(uvRect1.xMin, uvRect1.yMin), Vector3.zero, Vector4.zero); vh.AddVert(new Vector3(v.x, v.w), color32, new Vector2(uvRect0.xMin, uvRect0.yMax), new Vector2(uvRect1.xMin, uvRect1.yMax), Vector3.zero, Vector4.zero); vh.AddVert(new Vector3(v.z, v.w), color32, new Vector2(uvRect0.xMax, uvRect0.yMax), new Vector2(uvRect1.xMax, uvRect1.yMax), Vector3.zero, Vector4.zero); vh.AddVert(new Vector3(v.z, v.y), color32, new Vector2(uvRect0.xMax, uvRect0.yMin), new Vector2(uvRect1.xMax, uvRect1.yMin), Vector3.zero, Vector4.zero); vh.AddTriangle(index + 0, index + 1, index + 2); vh.AddTriangle(index + 2, index + 3, index + 0); index += 4; } }
protected virtual void SetIconDicingPattern(AssetFile file, string pattern) { DicingImage dicing = ChangeIconComponent <DicingImage>(); DicingTextures dicingTexture = file.UnityObject as DicingTextures; dicing.DicingData = dicingTexture; dicing.ChangePattern(pattern); dicing.UvRect = new Rect(0, 0, 1, 1); ChangeReference(file, dicing.gameObject); }
private void SetIconDicingPattern(AssetFile file, string pattern) { DicingImage image = this.ChangeIconComponent <DicingImage>(); DicingTextures unityObject = file.UnityObject as DicingTextures; image.DicingData = unityObject; image.ChangePattern(pattern); image.UvRect = new Rect(0f, 0f, 1f, 1f); this.ChangeReference(file, image.get_gameObject()); }
private void SetIconDicing(AdvGraphicInfo graphic, Rect rect) { DicingImage image = this.ChangeIconComponent <DicingImage>(); DicingTextures unityObject = graphic.File.UnityObject as DicingTextures; string subFileName = graphic.SubFileName; image.DicingData = unityObject; image.ChangePattern(subFileName); float width = image.PatternData.Width; float height = image.PatternData.Height; image.UvRect = rect.ToUvRect(width, height); this.ChangeReference(graphic.File, image.get_gameObject()); }
//ダイシングで表示する protected virtual void SetIconDicing(AdvGraphicInfo graphic, Rect rect) { DicingImage dicing = ChangeIconComponent <DicingImage>(); DicingTextures dicingTexture = graphic.File.UnityObject as DicingTextures; string pattern = graphic.SubFileName; dicing.DicingData = dicingTexture; dicing.ChangePattern(pattern); float w = dicing.PatternData.Width; float h = dicing.PatternData.Height; dicing.UvRect = rect.ToUvRect(w, h); ChangeReference(graphic.File, dicing.gameObject); }
public override void RebuildVertex(VertexHelper vh) { if (this.fadePatternData != null) { vh.Clear(); Rect pixelAdjustedRect = this.Target.GetPixelAdjustedRect(); Color color = this.Target.get_color(); DicingImage target = this.Target as DicingImage; float num = pixelAdjustedRect.get_width() / ((float)this.fadePatternData.Width); float num2 = pixelAdjustedRect.get_height() / ((float)this.fadePatternData.Height); int num3 = 0; List <DicingTextureData.QuadVerts> list = target.GetVerts(target.PatternData); List <DicingTextureData.QuadVerts> list2 = target.GetVerts(this.fadePatternData); int count = list.Count; if (count != list2.Count) { count = Mathf.Min(count, list2.Count); Debug.LogError(string.Format("Not equal texture size {0} and {1}", target.PatternData.Name, this.fadePatternData.Name)); } for (int i = 0; i < count; i++) { DicingTextureData.QuadVerts verts = list[i]; DicingTextureData.QuadVerts verts2 = list2[i]; if ((!target.SkipTransParentCell || !verts.isAllTransparent) || !verts2.isAllTransparent) { Vector4 vector = new Vector4(pixelAdjustedRect.get_x() + (num * verts.v.x), pixelAdjustedRect.get_y() + (num2 * verts.v.y), pixelAdjustedRect.get_x() + (num * verts.v.z), pixelAdjustedRect.get_y() + (num2 * verts.v.w)); Rect uvRect = verts.uvRect; Rect rect3 = verts2.uvRect; float introduced15 = uvRect.get_xMin(); float introduced16 = rect3.get_xMin(); vh.AddVert(new Vector3(vector.x, vector.y), color, new Vector2(introduced15, uvRect.get_yMin()), new Vector2(introduced16, rect3.get_yMin()), Vector3.get_zero(), Vector4.get_zero()); float introduced17 = uvRect.get_xMin(); float introduced18 = rect3.get_xMin(); vh.AddVert(new Vector3(vector.x, vector.w), color, new Vector2(introduced17, uvRect.get_yMax()), new Vector2(introduced18, rect3.get_yMax()), Vector3.get_zero(), Vector4.get_zero()); float introduced19 = uvRect.get_xMax(); float introduced20 = rect3.get_xMax(); vh.AddVert(new Vector3(vector.z, vector.w), color, new Vector2(introduced19, uvRect.get_yMax()), new Vector2(introduced20, rect3.get_yMax()), Vector3.get_zero(), Vector4.get_zero()); float introduced21 = uvRect.get_xMax(); float introduced22 = rect3.get_xMax(); vh.AddVert(new Vector3(vector.z, vector.y), color, new Vector2(introduced21, uvRect.get_yMin()), new Vector2(introduced22, rect3.get_yMin()), Vector3.get_zero(), Vector4.get_zero()); vh.AddTriangle(num3, num3 + 1, num3 + 2); vh.AddTriangle(num3 + 2, num3 + 3, num3); num3 += 4; } } } }
public override void OnPreviewGUI(Rect r, GUIStyle background) { DicingImage obj = this.target as DicingImage; if (obj == null) { return; } if (obj.DicingData == null) { return; } DicingTextureData patternData = obj.PatternData; if (patternData == null) { return; } OnPreviewGUISub(r, patternData); }
void OnPreviewGUISub(Rect r, DicingTextureData patternData) { DicingImage obj = this.target as DicingImage; obj.DicingData.OnPreviewGUI(patternData, r); }