// ---------------------------------------------------------------------------------- public static NcSpriteFactory.NcFrameInfo[] TileToTrimTexture(Material tarMat, int nTileX, int nTileY, int nStartFrame, int nFrameCount, int nMaxAtlasTextureSize) { if (tarMat == null) { return(null); } // split texture Texture2D tileTexture = CloneAtlasTexture(tarMat.mainTexture); List <Texture2D> frameTextures = new List <Texture2D>(); List <Rect> frameRects = new List <Rect>(); bool bFindAlpha; bool bFindBlack; NcSpriteFactory.NcFrameInfo[] frameInfos = NgAtlas.TrimTexture(tileTexture, true, true, nTileX, nTileY, nStartFrame, nFrameCount, ref frameTextures, ref frameRects, out bFindAlpha, out bFindBlack); // free tempTexture Object.DestroyImmediate(tileTexture); // packTextures Color clearColor = new Color(0, 0, 0, (bFindAlpha ? 0 : 1)); Texture2D AtlasTexture = new Texture2D(32, 32, TextureFormat.ARGB32, false); Rect[] uvRects = AtlasTexture.PackTextures(frameTextures.ToArray(), 2, nMaxAtlasTextureSize); // clear for (int x = 0; x < AtlasTexture.width; x++) { for (int y = 0; y < AtlasTexture.height; y++) { AtlasTexture.SetPixel(x, y, clearColor); } } // copy for (int n = 0; n < frameInfos.Length; n++) { int nFrameIndex = frameInfos[n].m_nFrameIndex; Rect imageUvRect = frameInfos[n].m_TextureUvOffset = uvRects[frameInfos[n].m_nFrameIndex]; AtlasTexture.SetPixels((int)(imageUvRect.x * AtlasTexture.width), (int)(imageUvRect.y * AtlasTexture.height), (int)(imageUvRect.width * AtlasTexture.width), (int)(imageUvRect.height * AtlasTexture.height), frameTextures[nFrameIndex].GetPixels()); Object.DestroyImmediate(frameTextures[n]); } SaveAtlasTexture(AtlasTexture, tarMat); Object.DestroyImmediate(AtlasTexture); return(frameInfos); }
public static string ExportSplitTexture(string tarBasePath, Texture srcTex, int nTileX, int nTileY, int nStartFrame, int nFrameCount) { #if UNITY_WEBPLAYER Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker."); Debug.Break(); return(""); #else if (srcTex == null) { return(""); } // split texture Texture2D tileTexture = CloneAtlasTexture(srcTex); List <Texture2D> frameTextures = new List <Texture2D>(); List <Rect> frameRects = new List <Rect>(); bool bFindAlpha; bool bFindBlack; NcSpriteFactory.NcFrameInfo[] frameInfos = NgAtlas.TrimTexture(tileTexture, false, false, nTileX, nTileY, nStartFrame, nFrameCount, ref frameTextures, ref frameRects, out bFindAlpha, out bFindBlack); // free tempTexture Object.DestroyImmediate(tileTexture); // create subFolder string filename = srcTex.name; string tarPath = NgFile.CombinePath(tarBasePath, filename); if (Directory.Exists(tarPath) == false) { Directory.CreateDirectory(tarPath); } // export for (int n = 0; n < frameInfos.Length; n++) { SaveTexture(frameTextures[n], tarPath, string.Format("{0}_{1:00}", filename, n)); Object.DestroyImmediate(frameTextures[n]); } return(tarPath); #endif }
// --------------------------------------------------------------------- public string EndCapture(Texture2D[] SpriteTextures) { #if UNITY_WEBPLAYER Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker."); Debug.Break(); return(null); #else int nTexSize = m_nResultTextureSize; int nCapSize = m_nResultCaptureSize; int nMaxCount = (nTexSize / nCapSize) * (nTexSize / nCapSize); int nTexHeight = (m_nSaveFrameCount <= nMaxCount / 2 ? nTexSize / 2 : nTexSize); Texture2D spriteTexture = new Texture2D(nTexSize, nTexHeight, TextureFormat.ARGB32, false); int nSaveCount = 0; for (int x = 0; x < spriteTexture.width; x++) { for (int y = 0; y < spriteTexture.height; y++) { spriteTexture.SetPixel(x, y, Color.black); } } for (int n = m_nSkipFrameCount; n < m_nTotalFrameCount; n++, nSaveCount++) { Color[] srcColors = SpriteTextures[n].GetPixels(0); if (m_ShaderType == SHADER_TYPE.ALPHA_BLENDED || m_ShaderType == SHADER_TYPE.ALPHA_BLENDED_MOBILE) { srcColors = NgAtlas.ConvertAlphaTexture(srcColors, true, FXMakerOption.inst.m_AlphaWeightCurve, 1, 1, 1); } spriteTexture.SetPixels(((nSaveCount) % (nTexSize / nCapSize)) * nCapSize, nTexHeight - (((nSaveCount) / (nTexSize / nCapSize) + 1) * nCapSize), nCapSize, nCapSize, srcColors); Object.DestroyImmediate(SpriteTextures[n]); } byte[] bytes = spriteTexture.EncodeToPNG(); string texBasePath; if (FXMakerLayout.m_bDevelopState) { texBasePath = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.SPRITE_TOOL); } else { texBasePath = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.SPRITE_USER); } string pathTexture = NgTexture.UniqueTexturePath(texBasePath, m_SelectedPrefabName); // save texture File.WriteAllBytes(pathTexture, bytes); AssetDatabase.Refresh(); NgTexture.ReimportTexture(pathTexture, m_bGUITexture, m_wrapMode, m_filterMode, m_anisoLevel, m_nSpriteTextureSizes[(int)m_fSpriteTextureIndex], m_SpriteTextureFormat[(int)m_fSpriteTextureFormatIdx]); Object.DestroyImmediate(spriteTexture); // Create Prefab if (m_bCreatePrefab) { string pathMaterial = CreateMaterial(pathTexture); Material newMat = (Material)AssetDatabase.LoadAssetAtPath(pathMaterial, typeof(Material)); GameObject newPrefab = (GameObject)Instantiate(FXMakerMain.inst.m_FXMakerSpritePrefab); newPrefab.transform.rotation = Quaternion.identity; newPrefab.GetComponent <Renderer>().material = newMat; NcSpriteAnimation spriteCom = newPrefab.GetComponent <NcSpriteAnimation>(); spriteCom.m_bBuildSpriteObj = true; spriteCom.m_nFrameCount = m_nSaveFrameCount; spriteCom.m_fFps = m_nResultFps; spriteCom.m_nTilingX = m_nResultTextureSize / m_nResultCaptureSize; spriteCom.m_nTilingY = (m_nSaveFrameCount <= spriteCom.m_nTilingX * spriteCom.m_nTilingX / 2 ? spriteCom.m_nTilingX / 2 : spriteCom.m_nTilingX); spriteCom.m_PlayMode = m_PlayMode; spriteCom.m_bLoop = m_bLoop; spriteCom.m_nLoopStartFrame = 0; spriteCom.m_nLoopFrameCount = spriteCom.m_nFrameCount; spriteCom.m_nLoopingCount = 0; spriteCom.m_bAutoDestruct = !m_bLoop; NcCurveAnimation curveCom = newPrefab.GetComponent <NcCurveAnimation>(); if (curveCom.GetCurveInfoCount() != 3) { Debug.LogError("FXMakerMain.inst.m_FxmSpritePrefab : curveCom Count Error!!!"); } curveCom.GetCurveInfo(0).m_bEnabled = false; // both curveCom.GetCurveInfo(1).m_bEnabled = false; // fadein curveCom.GetCurveInfo(2).m_bEnabled = false; // fadeout curveCom.m_bAutoDestruct = false; curveCom.m_fDurationTime = spriteCom.GetDurationTime(); if (m_bFadeIn && m_bFadeOut) { curveCom.GetCurveInfo(0).m_bEnabled = true; } else { if (m_bFadeIn) { curveCom.GetCurveInfo(1).m_bEnabled = true; } if (m_bFadeOut) { curveCom.GetCurveInfo(2).m_bEnabled = true; } } string basePath = AssetDatabase.GetAssetPath(FXMakerMain.inst.GetOriginalEffectPrefab()); string prefabPath = UniquePrefabPath(NgFile.TrimFilenameExt(basePath)); GameObject createPrefab = PrefabUtility.CreatePrefab(prefabPath, newPrefab); Destroy(newPrefab); // Create Thumb CreateSpriteThumb(createPrefab, pathTexture); AssetDatabase.SaveAssets(); return(prefabPath); } else { return(pathTexture); } #endif }
void winPopup(int id) { Rect baseRect = GetPopupRect(); Rect lineRect; int nMargin = 2; int nTopHeight = 1; int nLineCount = 25; int nIncLine = 0; string str; // if (UnfocusClose(baseRect, 5, 0, 0, 0)) // return; baseRect = FXMakerLayout.GetChildVerticalRect(baseRect, nTopHeight, 1, 0, 1); baseRect = FXMakerLayout.GetOffsetRect(baseRect, -nMargin); // Capture lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y + lineRect.height - 1), (int)lineRect.width, Color.grey, 2, false); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), "Capture"); // m_CaptureType lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("CaptureType"), false); m_CaptureType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), m_CaptureType == CAPTURE_TYPE.ANIMATION, new GUIContent("Animation"), true) ? CAPTURE_TYPE.ANIMATION : m_CaptureType; m_CaptureType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), m_CaptureType == CAPTURE_TYPE.RANDOM, new GUIContent("Random"), true) ? CAPTURE_TYPE.RANDOM : m_CaptureType; // size 32, 64, 128, 256, 512 lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Size"), false); m_nCaptureSizeIndex = (int)GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_nCaptureSizeIndex, 1, 0, m_nCaptureSizeValues.Length - 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_nCaptureSizeValues[m_nCaptureSizeIndex].ToString(), false); if (m_CaptureType == CAPTURE_TYPE.ANIMATION) { // frame lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Fps"), false); m_nFrameCountIndex = (int)GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_nFrameCountIndex, 1, 0, m_nFrameCountValues.Length); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_nFrameCountValues[m_nFrameCountIndex].ToString(), false); // Get Time lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 1, 0, 1), "Get Duration = " + FXMakerMain.inst.GetFXMakerControls().GetLastAutoRetTime().ToString("0.00"), true)) { m_fCaptureTime = System.Convert.ToSingle(FXMakerMain.inst.GetFXMakerControls().GetLastAutoRetTime().ToString("0.00")); } // Rescale Time lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Time"), false); m_fCaptureTime = GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_fCaptureTime, GetFrameTime(), GetFrameTime(), m_fMaxCaptureTime); str = FXMakerLayout.GUITextField(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_fCaptureTime.ToString(), true).Trim(); m_fCaptureTime = NgConvert.ToFloat(str, m_fCaptureTime); // SkipFrameCount lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("SkipFrame"), false); if (m_nTotalFrameCount <= m_nSkipFrameCount) { m_nSkipFrameCount = m_nTotalFrameCount - 1; } if (m_nTotalFrameCount <= 1) { m_nSkipFrameCount = 0; } else { m_nSkipFrameCount = (int)GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_nSkipFrameCount, 1, 0, m_nTotalFrameCount); } FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_nSkipFrameCount.ToString(), false); // total m_nTotalFrameCount = (int)(m_fCaptureTime / GetFrameTime()) + 1; m_nSaveFrameCount = (m_nTotalFrameCount - m_nSkipFrameCount); m_nResultFps = m_nFrameCountValues[m_nFrameCountIndex]; } if (m_CaptureType == CAPTURE_TYPE.RANDOM) { // m_nRandomCaptureCount lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("CaptureCount"), false); m_nRandomCaptureCount = (int)GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_nRandomCaptureCount, 1, 1, m_fMaxRandomCaptureCount); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_nRandomCaptureCount.ToString(), false); // SkipTime lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("SkipTime"), false); m_fCaptureTime = GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_fCaptureTime, 0.01f, 0, m_fMaxCaptureTime); str = FXMakerLayout.GUITextField(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_fCaptureTime.ToString(), true).Trim(); m_fCaptureTime = NgConvert.ToFloat(str, m_fCaptureTime); nIncLine += 2; // total m_nSkipFrameCount = 0; m_nTotalFrameCount = m_nRandomCaptureCount; m_nSaveFrameCount = m_nRandomCaptureCount; m_nResultFps = m_nFrameCountValues[m_nFrameCountIndex]; } // total frame lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("TotalFrame"), false); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 7), (m_nTotalFrameCount - m_nSkipFrameCount).ToString(), false); // m_nResultTextureSize m_nResultCaptureSize = m_nCaptureSizeValues[(int)m_nCaptureSizeIndex]; m_nResultTextureSize = NgAtlas.GetTextureSize(m_nSaveFrameCount, m_nResultCaptureSize); lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("TextureSize"), false); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 7), m_nResultTextureSize.ToString() + " x " + (m_nSaveFrameCount <= (m_nResultTextureSize / m_nResultCaptureSize) * (m_nResultTextureSize / m_nResultCaptureSize) / 2 ? m_nResultTextureSize / 2 : m_nResultTextureSize).ToString(), false); // ------------------------------------------------------------------------------------------------------------------------- // Output lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y + lineRect.height - 1), (int)lineRect.width, Color.grey, 2, false); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), "Output"); // bCreatePrefab lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Create"), false); m_bCreatePrefab = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), m_bCreatePrefab, new GUIContent("Prefab"), true); m_bCreatePrefab = !FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), !m_bCreatePrefab, new GUIContent("Texture"), true); // PlayMode lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("PlayMode"), false); if (FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), (m_bCreatePrefab && m_PlayMode == NcSpriteAnimation.PLAYMODE.DEFAULT), new GUIContent("Default"), m_bCreatePrefab)) { m_PlayMode = NcSpriteAnimation.PLAYMODE.DEFAULT; } if (FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), (m_bCreatePrefab && m_PlayMode == NcSpriteAnimation.PLAYMODE.INVERSE), new GUIContent("Inverse"), m_bCreatePrefab)) { m_PlayMode = NcSpriteAnimation.PLAYMODE.INVERSE; } lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); if (FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), (m_bCreatePrefab && m_PlayMode == NcSpriteAnimation.PLAYMODE.PINGPONG), new GUIContent("PingPong"), m_bCreatePrefab)) { m_PlayMode = NcSpriteAnimation.PLAYMODE.PINGPONG; } if (FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), (m_bCreatePrefab && m_PlayMode == NcSpriteAnimation.PLAYMODE.RANDOM), new GUIContent("Random"), m_bCreatePrefab)) { m_PlayMode = NcSpriteAnimation.PLAYMODE.RANDOM; } // Loop lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Loop"), false); if (m_bCreatePrefab) { m_bLoop = !FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), (m_bCreatePrefab && !m_bLoop), new GUIContent("Once"), m_bCreatePrefab); m_bLoop = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), (m_bCreatePrefab && m_bLoop), new GUIContent("Loop"), m_bCreatePrefab); } else { FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), (m_bCreatePrefab && m_bLoop), new GUIContent("Once"), m_bCreatePrefab); FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), (m_bCreatePrefab && !m_bLoop), new GUIContent("Loop"), m_bCreatePrefab); } // Shader lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Shader"), false); if (m_bCreatePrefab) { m_ShaderType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 7), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE), new GUIContent("Additive"), m_bCreatePrefab) ? SHADER_TYPE.ADDITIVE : m_ShaderType; m_ShaderType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 7), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE_MOBILE), new GUIContent("AdditiveMobile"), m_bCreatePrefab) ? SHADER_TYPE.ADDITIVE_MOBILE : m_ShaderType; lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); m_ShaderType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 7), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE_SOFT), new GUIContent("AdditiveSoft"), m_bCreatePrefab) ? SHADER_TYPE.ADDITIVE_SOFT : m_ShaderType; m_ShaderType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 7), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ALPHA_BLENDED), new GUIContent("AlphaBlended"), m_bCreatePrefab) ? SHADER_TYPE.ALPHA_BLENDED : m_ShaderType; lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); m_ShaderType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 13), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ALPHA_BLENDED_MOBILE), new GUIContent("AlphaBlendedMobile"), m_bCreatePrefab) ? SHADER_TYPE.ALPHA_BLENDED_MOBILE : m_ShaderType; } else { FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 5), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE), new GUIContent("Additive"), m_bCreatePrefab); FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 12, 4), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE_MOBILE), new GUIContent("Mobile"), m_bCreatePrefab); FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 17, 3), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE_SOFT), new GUIContent("Soft"), m_bCreatePrefab); lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 7), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ALPHA_BLENDED), new GUIContent("AlphaBlended"), m_bCreatePrefab); FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 14, 7), (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ALPHA_BLENDED_MOBILE), new GUIContent("AlphaBlendedMobile"), m_bCreatePrefab); } // Fade lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); bool bFade = (m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ADDITIVE || m_bCreatePrefab && m_ShaderType == SHADER_TYPE.ALPHA_BLENDED); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Fade"), false); if (bFade) { m_bFadeIn = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), m_bFadeIn, new GUIContent("FadeIn"), bFade); m_bFadeOut = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), m_bFadeOut, new GUIContent("FadeOut"), bFade); } else { FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6), false, new GUIContent("FadeIn"), bFade); FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6), false, new GUIContent("FadeOut"), bFade); } // Texture Format --------------------------------------------------------------------------------------- // TextureType lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("TextureType"), false); m_bGUITexture = FXMakerLayout.GUIToggle(GetToggleRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 7, 6)), m_bGUITexture, new GUIContent("GUI"), true); m_bGUITexture = !FXMakerLayout.GUIToggle(GetToggleRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 20, 13, 6)), !m_bGUITexture, new GUIContent("Texture"), true); // AnisoLevel lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("AnisoLevel"), false); if (!m_bGUITexture) { m_anisoLevel = (int)GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_anisoLevel, 1, 0, 9 + 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_anisoLevel.ToString(), false); } // m_nSpriteTextureSizes lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("MaxSize"), false); m_fSpriteTextureIndex = GUI.HorizontalScrollbar(GetScrollbarRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 3, 5)), m_fSpriteTextureIndex, 1, 0, m_nSpriteTextureSizes.Length - 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 8, 2), m_nSpriteTextureSizes[(int)m_fSpriteTextureIndex].ToString(), false); // m_nSpriteTextureFormat lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 10, 0, 3), GetHelpContent("Format"), false); lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); for (int n = 0; n < m_SpriteTextureFormatName.Length; n++) { Rect toggleRect = GetToggleRect(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, n, 1)); if (n == 2) { toggleRect.x -= 15; toggleRect.width += 15; } bool bCheck = (GUI.Toggle(toggleRect, (m_fSpriteTextureFormatIdx == n), m_SpriteTextureFormatName[n])); if (bCheck && m_fSpriteTextureFormatIdx != n) { m_fSpriteTextureFormatIdx = n; // EditorPrefs.SetInt("FxmSpritePopup.m_nShowGameObjectOptionIndex", m_nShowGameObjectOptionIndex); } } nIncLine++; lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nLineCount, nIncLine++, 1); lineRect = FXMakerLayout.GetOffsetRect(lineRect, 0, -12, 0, 0); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 2, 0, 1), "Build Sprite", (m_nResultTextureSize <= 2048))) { FXMakerCapture.StartSpriteCapture(m_CaptureType, m_nTotalFrameCount, (m_CaptureType == CAPTURE_TYPE.ANIMATION ? GetFrameTime() : m_fCaptureTime), GetSpriteCaptureRect()); ClosePopup(); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 2, 1, 1), "Close", true)) { ClosePopup(); } FXMakerMain.inst.SaveTooltip(); }
Texture2D BuildSpriteAtlas() { List <Texture2D> frameTextures = new List <Texture2D>(); List <Rect> frameRects = new List <Rect>(); bool bCheckAlpha = false; List <Texture2D> loadTextures = new List <Texture2D>(); List <NcSpriteFactory.NcFrameInfo[]> loadFrameInfos = new List <NcSpriteFactory.NcFrameInfo[]>(); NcSpriteFactory.NcFrameInfo[] frameInfo; // bool bCheckBlack = false; for (int n = 0; n < m_Sel.m_SpriteList.Count; n++) { if (m_Sel.m_SpriteList[n].IsUnused()) { continue; } bool bFindAlpha; bool bFindBlack; Texture2D selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(m_Sel.m_SpriteList[n].m_TextureGUID), typeof(Texture2D)); int nFindIndex = loadTextures.IndexOf(selTexture); if (0 <= nFindIndex) { bFindAlpha = false; bFindBlack = false; frameInfo = loadFrameInfos[nFindIndex]; } else { NgAtlas.SetSourceTexture(selTexture); frameInfo = NgAtlas.TrimTexture(selTexture, m_Sel.m_bTrimBlack, m_Sel.m_bTrimAlpha, m_Sel.m_SpriteList[n].m_nTilingX, m_Sel.m_SpriteList[n].m_nTilingY, m_Sel.m_SpriteList[n].m_nStartFrame, m_Sel.m_SpriteList[n].m_nFrameCount, ref frameTextures, ref frameRects, out bFindAlpha, out bFindBlack); loadTextures.Add(selTexture); loadFrameInfos.Add(m_Sel.m_SpriteList[n].m_FrameInfos); } m_Sel.m_SpriteList[n].m_FrameInfos = frameInfo; if (bFindAlpha) { bCheckAlpha = true; } // if (bFindBlack) // bCheckBlack = true; // Debug.Log(m_Sel.m_SpriteList[n].m_FrameInfos[0].m_FrameUvOffset); } Color clearColor = new Color(0, 0, 0, (bCheckAlpha ? 0 : 1)); Texture2D AtlasTexture = new Texture2D(32, 32, TextureFormat.ARGB32, false); Rect[] uvRects = AtlasTexture.PackTextures(frameTextures.ToArray(), 2, m_Sel.m_nMaxAtlasTextureSize); // clear for (int x = 0; x < AtlasTexture.width; x++) { for (int y = 0; y < AtlasTexture.height; y++) { AtlasTexture.SetPixel(x, y, clearColor); } } // copy for (int n = 0; n < m_Sel.m_SpriteList.Count; n++) { if (m_Sel.m_SpriteList[n].IsUnused()) { m_Sel.m_SpriteList[n].SetEmpty(); continue; } for (int fc = 0; fc < m_Sel.m_SpriteList[n].m_FrameInfos.Length; fc++) { int nFrameIndex = m_Sel.m_SpriteList[n].m_FrameInfos[fc].m_nFrameIndex; Rect imageUvRect = m_Sel.m_SpriteList[n].m_FrameInfos[fc].m_TextureUvOffset = uvRects[m_Sel.m_SpriteList[n].m_FrameInfos[fc].m_nFrameIndex]; // 알파조정 처리 Color[] colBuf = frameTextures[nFrameIndex].GetPixels(); for (int an = 0; an < colBuf.Length; an++) { if (m_Sel.m_SpriteList[n].m_fMaxTextureAlpha < colBuf[an].a) { colBuf[an].a = m_Sel.m_SpriteList[n].m_fMaxTextureAlpha; } } AtlasTexture.SetPixels((int)(imageUvRect.x * AtlasTexture.width), (int)(imageUvRect.y * AtlasTexture.height), (int)(imageUvRect.width * AtlasTexture.width), (int)(imageUvRect.height * AtlasTexture.height), colBuf); } } for (int n = 0; n < frameTextures.Count; n++) { Object.DestroyImmediate(frameTextures[n]); } return(AtlasTexture); }
public override void OnInspectorGUI() { Rect rect; AddScriptNameField(m_Sel); m_UndoManager.CheckUndo(); m_FxmPopupManager = GetFxmPopupManager(); // test code // if (GUILayout.Button("Pause")) // FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcSpriteAnimation>().PauseAnimation(); // if (GUILayout.Button("Resume")) // FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcSpriteAnimation>().ResumeAnimation(); // -------------------------------------------------------------- bool bClickButton = false; EditorGUI.BeginChangeCheck(); { // DrawDefaultInspector(); m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag); m_Sel.m_TextureType = (NcSpriteAnimation.TEXTURE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_TextureType"), m_Sel.m_TextureType); EditorGUILayout.Space(); if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture) { if (GUILayout.Button(GetHelpContent("ConvertTo : TrimTexture"))) { m_Sel.m_NcSpriteFrameInfos = NgAtlas.TileToTrimTexture(m_Sel.renderer.sharedMaterial, m_Sel.m_nTilingX, m_Sel.m_nTilingY, 0, m_Sel.m_nFrameCount, 4096); if (m_Sel.m_NcSpriteFrameInfos != null) { m_Sel.m_TextureType = NcSpriteAnimation.TEXTURE_TYPE.TrimTexture; } } if (GUILayout.Button(GetHelpContent("ExportTo : SplitTexture"))) { string path = FXMakerCapture.GetExportSlitDir(); path = NgAtlas.ExportSplitTexture(path, m_Sel.renderer.sharedMaterial.mainTexture, m_Sel.m_nTilingX, m_Sel.m_nTilingY, 0, m_Sel.m_nFrameCount); if (path != "") { Debug.Log(path); EditorUtility.OpenWithDefaultApp(path); } } } else if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TrimTexture) { if (GUILayout.Button(GetHelpContent("ExportTo : SplitTexture"))) { string path = FXMakerCapture.GetExportSlitDir(); path = NgAtlas.ExportSplitTexture(path, m_Sel.renderer.sharedMaterial.mainTexture, m_Sel.m_NcSpriteFrameInfos); if (path != "") { Debug.Log(path); EditorUtility.OpenWithDefaultApp(path); } } } else if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.SpriteFactory) { } EditorGUILayout.Space(); if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture) { m_Sel.m_nTilingX = EditorGUILayout.IntField(GetHelpContent("m_nTilingX"), m_Sel.m_nTilingX); m_Sel.m_nTilingY = EditorGUILayout.IntField(GetHelpContent("m_nTilingY"), m_Sel.m_nTilingY); } else if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TrimTexture) { m_Sel.m_MeshType = (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType); m_Sel.m_AlignType = (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType); m_Sel.m_bTrimCenterAlign = EditorGUILayout.Toggle("m_bTrimCenterAlign", m_Sel.m_bTrimCenterAlign); } else if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.SpriteFactory) { m_Sel.m_NcSpriteFactoryPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_NcSpriteFactoryPrefab"), m_Sel.m_NcSpriteFactoryPrefab, typeof(GameObject), false, null); // -------------------------------------------------------------- EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight)); { if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("Select SpriteFactory"), (m_FxmPopupManager != null))) { m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, true, 0); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("Clear SpriteFactory"), (m_Sel.m_NcSpriteFactoryPrefab != null))) { bClickButton = true; m_Sel.m_NcSpriteFactoryPrefab = null; } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); // -------------------------------------------------------------- if (m_Sel.m_NcSpriteFactoryPrefab != null && m_Sel.m_NcSpriteFactoryPrefab.renderer != null && m_Sel.renderer) { if (m_Sel.m_NcSpriteFactoryPrefab.renderer.sharedMaterial != m_Sel.renderer.sharedMaterial) { m_Sel.UpdateFactoryMaterial(); } } // -------------------------------------------------------------- NcSpriteFactory ncSpriteFactory = (m_Sel.m_NcSpriteFactoryPrefab == null ? null : m_Sel.m_NcSpriteFactoryPrefab.GetComponent <NcSpriteFactory>()); if (ncSpriteFactory != null) { int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nSpriteFactoryIndex"), m_Sel.m_nSpriteFactoryIndex, 0, ncSpriteFactory.GetSpriteNodeCount() - 1); if (m_Sel.m_nSpriteFactoryIndex != nSelIndex) { m_Sel.SetSpriteFactoryIndex(nSelIndex, false); } } m_Sel.m_MeshType = (NcSpriteFactory.MESH_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_MeshType"), m_Sel.m_MeshType); m_Sel.m_AlignType = (NcSpriteFactory.ALIGN_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_AlignType"), m_Sel.m_AlignType); m_Sel.m_bTrimCenterAlign = EditorGUILayout.Toggle("m_bTrimCenterAlign", m_Sel.m_bTrimCenterAlign); } m_Sel.m_PlayMode = (NcSpriteAnimation.PLAYMODE)EditorGUILayout.EnumPopup(GetHelpContent("m_PlayMode"), m_Sel.m_PlayMode, GUILayout.MaxWidth(Screen.width)); if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT) { m_Sel.m_fDelayTime = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime); } m_Sel.m_nStartFrame = EditorGUILayout.IntField(GetHelpContent("m_nStartFrame"), m_Sel.m_nStartFrame); m_Sel.m_nFrameCount = EditorGUILayout.IntField(GetHelpContent("m_nFrameCount"), m_Sel.m_nFrameCount); if (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT) { m_Sel.m_nSelectFrame = EditorGUILayout.IntField(GetHelpContent("m_nSelectFrame"), m_Sel.m_nSelectFrame); } if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.RANDOM && m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT) { bool bOldLoop = m_Sel.m_bLoop; m_Sel.m_bLoop = EditorGUILayout.Toggle(GetHelpContent("m_bLoop"), m_Sel.m_bLoop); if (!bOldLoop && m_Sel.m_bLoop) { m_Sel.m_nLoopStartFrame = 0; m_Sel.m_nLoopFrameCount = m_Sel.m_nFrameCount; m_Sel.m_nLoopingCount = 0; } if (m_Sel.m_bLoop && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.DEFAULT) { m_Sel.m_nLoopStartFrame = EditorGUILayout.IntField(" nLoopStartFrame", m_Sel.m_nLoopStartFrame); m_Sel.m_nLoopFrameCount = EditorGUILayout.IntField(" nLoopFrameCount", m_Sel.m_nLoopFrameCount); m_Sel.m_nLoopingCount = EditorGUILayout.IntField(" nLoopingCount", m_Sel.m_nLoopingCount); } if (m_Sel.m_bLoop == false || 0 < m_Sel.m_nLoopingCount) { m_Sel.m_bAutoDestruct = EditorGUILayout.Toggle(GetHelpContent("m_bAutoDestruct"), m_Sel.m_bAutoDestruct); } m_Sel.m_fFps = EditorGUILayout.FloatField(GetHelpContent("m_fFps"), m_Sel.m_fFps); } // check SetMinValue(ref m_Sel.m_nTilingX, 1); SetMinValue(ref m_Sel.m_nTilingY, 1); SetMinValue(ref m_Sel.m_fFps, 0.1f); SetMinValue(ref m_Sel.m_fDelayTime, 0); SetMaxValue(ref m_Sel.m_nStartFrame, m_Sel.GetMaxFrameCount() - 1); SetMinValue(ref m_Sel.m_nStartFrame, 0); SetMaxValue(ref m_Sel.m_nFrameCount, m_Sel.GetValidFrameCount()); SetMinValue(ref m_Sel.m_nFrameCount, 1); SetMaxValue(ref m_Sel.m_nSelectFrame, (0 < m_Sel.m_nFrameCount ? m_Sel.m_nFrameCount - 1 : m_Sel.m_nTilingX *m_Sel.m_nTilingY - 1)); SetMinValue(ref m_Sel.m_nSelectFrame, 0); SetMaxValue(ref m_Sel.m_nLoopStartFrame, m_Sel.m_nFrameCount - 1); SetMinValue(ref m_Sel.m_nLoopStartFrame, 0); SetMinValue(ref m_Sel.m_nLoopFrameCount, 0); SetMaxValue(ref m_Sel.m_nLoopFrameCount, m_Sel.m_nFrameCount - m_Sel.m_nLoopStartFrame); SetMinValue(ref m_Sel.m_nLoopingCount, 0); if (m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.RANDOM && m_Sel.m_PlayMode != NcSpriteAnimation.PLAYMODE.SELECT) { EditorGUILayout.TextField(GetHelpContent("DurationTime"), m_Sel.GetDurationTime().ToString()); } // Texture -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(150)); { GUI.Box(rect, ""); GUILayout.Label(""); Rect subRect = rect; // draw texture if (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null && m_Sel.renderer.sharedMaterial.mainTexture != null) { int nClickFrameIndex; if (m_Sel.m_TextureType == NcSpriteAnimation.TEXTURE_TYPE.TileTexture) { if (DrawTileTexture(subRect, (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT), m_Sel.renderer.sharedMaterial, m_Sel.m_nTilingX, m_Sel.m_nTilingY, m_Sel.m_nStartFrame, m_Sel.m_nFrameCount, m_Sel.m_nSelectFrame, out nClickFrameIndex)) { bClickButton = true; if (bClickButton && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT) { m_Sel.m_nSelectFrame = nClickFrameIndex; } } } if (m_Sel.m_TextureType != NcSpriteAnimation.TEXTURE_TYPE.TileTexture) { if (DrawTrimTexture(subRect, (m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT), m_Sel.renderer.sharedMaterial, m_Sel.m_NcSpriteFrameInfos, m_Sel.m_nStartFrame, m_Sel.m_nFrameCount, m_Sel.m_nSelectFrame, out nClickFrameIndex)) { bClickButton = true; if (bClickButton && m_Sel.m_PlayMode == NcSpriteAnimation.PLAYMODE.SELECT) { m_Sel.m_nSelectFrame = nClickFrameIndex; } } } } } EditorGUILayout.EndHorizontal(); m_UndoManager.CheckDirty(); EditorGUILayout.Space(); // Remove AlphaChannel if (GUILayout.Button(GetHelpContent("Remove AlphaChannel"))) { NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, false, m_Sel.m_curveAlphaWeight, 1, 1, 1); } // AlphaWeight if ((m_Sel.m_curveAlphaWeight == null || m_Sel.m_curveAlphaWeight.length <= 0) && FXMakerOption.inst != null) { m_Sel.m_curveAlphaWeight = FXMakerOption.inst.m_AlphaWeightCurve; } if (m_Sel.m_curveAlphaWeight != null) { bool bHighLight = m_Sel.m_bNeedRebuildAlphaChannel; if (bHighLight) { FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox); } if (GUILayout.Button(GetHelpContent("Adjust the alpha channel with AlphaWeight"))) { m_Sel.m_bNeedRebuildAlphaChannel = false; NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, true, m_Sel.m_curveAlphaWeight, 1, 1, 1); // NgAtlas.ConvertAlphaTexture(m_Sel.renderer.sharedMaterial, m_Sel.m_curveAlphaWeight, m_Sel.m_fRedAlphaWeight, m_Sel.m_fGreenAlphaWeight, m_Sel.m_fBlueAlphaWeight); } if (bHighLight) { FXMakerLayout.GUIColorRestore(); } EditorGUI.BeginChangeCheck(); m_Sel.m_curveAlphaWeight = EditorGUILayout.CurveField(GetHelpContent("m_curveAlphaWeight"), m_Sel.m_curveAlphaWeight); if (EditorGUI.EndChangeCheck()) { m_Sel.m_bNeedRebuildAlphaChannel = true; } // m_Sel.m_fRedAlphaWeight = EditorGUILayout.Slider("", m_Sel.m_fRedAlphaWeight , 0, 1.0f); // m_Sel.m_fGreenAlphaWeight = EditorGUILayout.Slider("", m_Sel.m_fGreenAlphaWeight , 0, 1.0f); // m_Sel.m_fBlueAlphaWeight = EditorGUILayout.Slider("", m_Sel.m_fBlueAlphaWeight , 0, 1.0f); } EditorGUILayout.Space(); } // -------------------------------------------------------------- if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain()) { OnEditComponent(); } // --------------------------------------------------------------------- if (GUI.tooltip != "") { m_LastTooltip = GUI.tooltip; } HelpBox(m_LastTooltip); }