void SetActiveMaterialColor(Color newColor) { Material newMat = m_SelectedMaterial; // Create mat if (m_SelectedMaterial == null) { newMat = CreateDefaultMaterial(); } else { if (m_SelectedMaterial == m_OriMaterial) { newMat = new Material(m_SelectedMaterial); } } // Change Color NgMaterial.SetMaterialColor(newMat, newColor); if (m_NewShaderMaterials != null) { foreach (Material mat in m_NewShaderMaterials) { NgMaterial.SetMaterialColor(mat, newColor); } } // Current Change SetSelectedTransformMaterial(newMat); }
void AddObjects(string loaddir) { // StartCoroutine("NgAsset.GetTextureList()"); m_LoadDirectory = NgFile.PathSeparatorNormalize(loaddir); // m_TextureObjects = NgAsset.GetTextureList(loaddir, true, FXMakerLayout.m_nMaxTextureListCount, out m_nObjectCount); m_ObjectNodes = NgAsset.GetTextureList(loaddir, true, FXMakerLayout.m_nMaxTextureListCount, true, out m_nObjectCount); m_ObjectContents = new GUIContent[m_nObjectCount]; if (m_SelectedMaterial != null) { Texture maskTex = NgMaterial.GetMaskTexture(m_SelectedMaterial); m_nSelMainTextureIndex = -1; m_nSelMaskTextureIndex = -1; string selTexPath = AssetDatabase.GetAssetPath(m_SelectedMaterial.mainTexture); string selMaskPath = (maskTex != null ? AssetDatabase.GetAssetPath(maskTex) : null); for (int n = 0; n < m_nObjectCount; n++) { // Current Select if (m_ObjectNodes[n].m_AssetPath == selTexPath) { m_nSelMainTextureIndex = m_nObjectIndex = n; } // Current Mask Select if (m_ObjectNodes[n].m_AssetPath == selMaskPath) { m_nSelMaskTextureIndex = n; } } } BuildContents(); }
void CreateNewShaderMaterials(Material currentMat) { if (m_NewShaderMaterials != null && FXMakerOption.inst.m_bUpdateNewMaterial == false) { return; } // Load m_DefaultShaderMaterialsDir int nMaterialCount; m_NewShaderMaterials = NgAsset.GetMaterialList(FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.DEFAULTSHADERMATERIALS), true, 0, out nMaterialCount); m_NewShaderMaterialContents = null; // Change Texture if (m_NewShaderMaterials != null) { foreach (Material mat in m_NewShaderMaterials) { NgMaterial.CopyMaterialArgument(currentMat, mat); } FXMakerAsset.AssetDatabaseSaveAssets(); m_nTempSaveFrameIndex = FXMakerMain.inst.GetUnityFrameCount(); m_NewShaderMaterialContents = new GUIContent[m_NewShaderMaterials.Length]; // build content BuildNewShaderContents(); } }
string CreateMaterial(string pathTexture) { Material newMat; // Shader switch (m_ShaderType) { case SHADER_TYPE.ADDITIVE: newMat = new Material(Shader.Find("Particles/Additive")); break; case SHADER_TYPE.ADDITIVE_MOBILE: newMat = new Material(Shader.Find("Mobile/Particles/Additive")); break; case SHADER_TYPE.ADDITIVE_SOFT: newMat = new Material(Shader.Find("Particles/Additive (Soft)")); break; case SHADER_TYPE.ALPHA_BLENDED: newMat = new Material(Shader.Find("Particles/Alpha Blended")); break; case SHADER_TYPE.ALPHA_BLENDED_MOBILE: newMat = new Material(Shader.Find("Mobile/Particles/Alpha Blended")); break; default: { Debug.LogError("Missing m_ShaderType"); return(""); } } newMat.mainTexture = (Texture)AssetDatabase.LoadAssetAtPath(pathTexture, typeof(Texture)); return(NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(pathTexture), NgFile.GetFilename(pathTexture), FXMakerLayout.m_bDevelopState)); }
public static Material ObjectCopy(Material src, Transform dstSelTrans, int nDstSelIndex) { if (dstSelTrans.GetComponent <Renderer>() != null) { return(NgMaterial.SetSharedMaterial(dstSelTrans.GetComponent <Renderer>(), nDstSelIndex, src)); } return(null); }
public void PasteClipboardColor(Transform tarTransform, int tarMatIndex, Material tarMat) { if (NgMaterial.IsMaterialColor(tarMat)) { // NgMaterial.SetMaterialColor(tarMat, m_CopyColor); FxmPopupManager.inst.ChangeMaterialColor(tarTransform, tarMatIndex, m_CopyColor); } }
protected void winAlpha1(int id) { Texture tex = NgMaterial.GetTexture(m_SelectedMaterial, true); if (tex != null) { Rect rect = FXMakerLayout.GetOffsetRect(new Rect(0, m_nPreviewCaptionHeight, m_nPreviewMaterialWidth - m_nPreviewCaptionHeight, m_nPreviewMaterialWidth - m_nPreviewCaptionHeight), -4); EditorGUI.DrawTextureAlpha(rect, tex); } }
void SetActiveMaterial(Material srcMaterial, Texture newTexture, bool bNewShaderMaterial, bool bMaskTex) { Material newMat = m_SelectedMaterial; // Create mat if (srcMaterial != null) { newMat = new Material(srcMaterial); } else { if (m_SelectedMaterial == null) { newMat = CreateDefaultMaterial(); } else { // �ؽ��� ���� if (m_SelectedMaterial == m_OriMaterial) { newMat = new Material(m_SelectedMaterial); } } } // Set Property if (newTexture != null) { NgMaterial.SetMaskTexture(newMat, bMaskTex, newTexture); if (newMat.mainTexture == null) { newMat.name = newTexture.name; } else { newMat.name = newMat.mainTexture.name; } } // Current Change SetSelectedTransformMaterial(newMat); if (bNewShaderMaterial) { m_nCurrentTextureMaterialIndex = -1; } else if (newTexture != null) { m_nNewShaderMaterialIndex = -1; } // Reinstance FXMakerMain.inst.CreateCurrentInstanceEffect(true); }
public static void CopyMaterialArgument(Material srcMat, Material tarMat) { tarMat.mainTexture = srcMat.mainTexture; tarMat.mainTextureOffset = srcMat.mainTextureOffset; tarMat.mainTextureScale = srcMat.mainTextureScale; if (NgMaterial.IsMaskTexture(srcMat) && NgMaterial.IsMaskTexture(tarMat)) { NgMaterial.SetMaskTexture(tarMat, NgMaterial.GetMaskTexture(srcMat)); } NgMaterial.SetMaterialColor(tarMat, NgMaterial.GetMaterialColor(srcMat, new Color(0.5f, 0.5f, 0.5f, 0.5f))); }
public static void SetMaskTexture(Material mat, bool bMask, Texture newTexture) { if (mat == null) { return; } if (bMask) { NgMaterial.SetMaskTexture(mat, newTexture); } else { mat.mainTexture = newTexture; } }
public override void ClosePopup(bool bSave) { if (enabled == false) { return; } // Save Material if (bSave && m_SelectedMaterial != null && NgMaterial.IsSameMaterial(m_SelectedMaterial, m_OriMaterial, true) == false) { SaveMaterial(m_SelectedMaterial); } m_SelectedMaterial = null; base.ClosePopup(bSave); }
public static Texture GetTexture(Material mat, bool bMask) { if (mat == null) { return(null); } if (!bMask) { return(mat.mainTexture); } if (NgMaterial.IsMaskTexture(mat)) { return(mat.GetTexture("_Mask")); } return(null); }
// ---------------------------------------------------------------------------------------------------------- protected override void SetActiveObject(int nObjectIndex) { if (nObjectIndex < 0 || m_nObjectCount <= nObjectIndex) { return; } Texture selTexture = GetObjectNodeTexture(nObjectIndex); bool bMaskTex = false; // right button, image Ping and not select if (Input.GetMouseButtonUp(1)) { if (m_SelectedMaterial != null && NgMaterial.IsMaskTexture(m_SelectedMaterial)) { m_nSelMaskTextureIndex = nObjectIndex; bMaskTex = true; } else { FXMakerAsset.SetPingObject(selTexture); return; } } else { m_nSelMainTextureIndex = nObjectIndex; } // // ������ ��Ŭ�� // if (m_nObjectIndex == nObjectIndex) // { // FXMakerAsset.SetPingObject(m_SelectedMaterial); // FXMakerMain.inst.CreateCurrentInstanceEffect(true); // return; // } SetActiveObject(selTexture, bMaskTex); // GUI Update m_nObjectIndex = nObjectIndex; m_nSelObjectProjectIndex = m_nProjectIndex; m_nSelObjectGroupIndex = (m_bOptionRecursively ? -1 : m_nGroupIndex); m_SelObjectContent = new GUIContent(m_ObjectContents[nObjectIndex].text, m_ObjectContents[nObjectIndex].image, m_ObjectContents[nObjectIndex].tooltip); }
protected void SetActiveObject(Texture selTexture, bool bMaskTex) { if (selTexture == null) { return; } // Create Mat if (m_SelectedMaterial == null || NgMaterial.GetTexture(m_SelectedMaterial, bMaskTex) != selTexture) { SetActiveMaterial(null, selTexture, false, bMaskTex); } // Find NewTexture Materials FindCurrentTextureMaterials(m_SelectedMaterial); // Create NewShader Materials CreateNewShaderMaterials(m_SelectedMaterial); m_SelectedTextureMaterials = m_CurrentTextureMaterials; }
public override void OnGUIPopup() { base.OnGUIPopup(); // Popup Window --------------------------------------------------------- // FXMakerMain.inst.PopupFocusWindow(NgLayout.GetWindowId(NgLayout.WINDOWID.POPUP), GetPopupRect(), winPopup, "Material"); FXMakerMain.inst.ModalMsgWindow(FXMakerLayout.GetWindowId(FXMakerLayout.WINDOWID.POPUP), GetPopupRect(), winPopup, "Material"); if (NgMaterial.GetTexture(m_SelectedMaterial, true) != null) { DrawPreviewMaterial(1, NgMaterial.GetTexture(m_SelectedMaterial, false)); DrawPreviewMaterial(0, NgMaterial.GetTexture(m_SelectedMaterial, true)); } else { if (NgMaterial.GetTexture(m_SelectedMaterial, false) != null) { DrawPreviewMaterial(0, NgMaterial.GetTexture(m_SelectedMaterial, false)); } } }
public override void OnInspectorGUI() { AddScriptNameField(m_Sel); int nClickIndex = -1; int nClickButton = 0; Rect rect; int nLeftWidth = 34; int nAddHeight = 30; int nDelWidth = 35; int nLineHeight = 18; int nSpriteHeight = nLeftWidth; List <NcSpriteFactory.NcSpriteNode> spriteList = m_Sel.m_SpriteList; m_FxmPopupManager = GetFxmPopupManager(); // -------------------------------------------------------------- bool bClickButton = false; EditorGUI.BeginChangeCheck(); { m_UndoManager.CheckUndo(); // -------------------------------------------------------------- m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag); EditorGUILayout.Space(); m_Sel.m_SpriteType = (NcSpriteFactory.SPRITE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_SpriteType"), m_Sel.m_SpriteType); // -------------------------------------------------------------- if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && m_Sel.gameObject.GetComponent("NcSpriteAnimation") == null) { rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight)); { if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteAnimation Component"), true)) { m_Sel.gameObject.AddComponent("NcSpriteAnimation"); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); } // -------------------------------------------------------------- if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture && m_Sel.gameObject.GetComponent("NcSpriteTexture") == null) { rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight)); { if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteTexture Component"), true)) { m_Sel.gameObject.AddComponent("NcSpriteTexture"); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); // -------------------------------------------------------------- int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nCurrentIndex"), m_Sel.m_nCurrentIndex, 0, (spriteList == null ? 0 : spriteList.Count - 1)); float fUvScale = EditorGUILayout.FloatField(GetHelpContent("m_fUvScale"), m_Sel.m_fUvScale); if (m_Sel.m_nCurrentIndex != nSelIndex || fUvScale != m_Sel.m_fUvScale) { m_Sel.m_nCurrentIndex = nSelIndex; m_Sel.m_fUvScale = fUvScale; m_Sel.SetSprite(nSelIndex, false); } // Rebuild Check EditorGUI.BeginChangeCheck(); m_Sel.m_bTrimBlack = EditorGUILayout.Toggle(GetHelpContent("m_bTrimBlack"), m_Sel.m_bTrimBlack); m_Sel.m_bTrimAlpha = EditorGUILayout.Toggle(GetHelpContent("m_bTrimAlpha"), m_Sel.m_bTrimAlpha); m_Sel.m_nMaxAtlasTextureSize = EditorGUILayout.IntPopup("nMaxAtlasTextureSize", m_Sel.m_nMaxAtlasTextureSize, NgEnum.m_TextureSizeStrings, NgEnum.m_TextureSizeIntters); // m_Sel.m_AtlasMaterial = (Material)EditorGUILayout.ObjectField(GetHelpContent("m_AtlasMaterial") , m_Sel.m_AtlasMaterial, typeof(Material), false); if (EditorGUI.EndChangeCheck()) { m_Sel.m_bNeedRebuild = true; } // check // Add Button ------------------------------------------------------ EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight * 2)); { Rect lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1); if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Add Sprite"))) { bClickButton = true; m_Sel.AddSpriteNode(); } bool bHighLight = m_Sel.m_bNeedRebuild; if (bHighLight) { FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox); } if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("Build Sprite"))) { #if UNITY_WEBPLAYER Debug.LogError("In WEB_PLAYER mode, you cannot run the FXMaker."); Debug.Break(); #else bClickButton = true; CreateSpriteAtlas(m_Sel.renderer.sharedMaterial); m_Sel.m_bNeedRebuild = false; #endif } if (bHighLight) { FXMakerLayout.GUIColorRestore(); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 2, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetSpriteNodeCount()))) { bClickButton = true; if (m_FxmPopupManager != null) { m_FxmPopupManager.CloseNcPrefabPopup(); } m_Sel.ClearAllSpriteNode(); } lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Sequence"), (0 < m_Sel.GetSpriteNodeCount()))) { m_Sel.m_bSequenceMode = true; bClickButton = true; m_Sel.SetSprite(0, false); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("NewMaterial"), true)) { Material newMat = new Material(m_Sel.renderer.sharedMaterial); string matPath = AssetDatabase.GetAssetPath(m_Sel.renderer.sharedMaterial); NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(matPath), m_Sel.name); m_Sel.renderer.sharedMaterial = newMat; // m_Sel.renderer.sharedMaterial = (Material)AssetDatabase.LoadAssetAtPath(savePath, typeof(Material)); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); // Select ShotType ------------------------------------------------- // showType = (NcSpriteFactory.SHOW_TYPE)EditorGUILayout.EnumPopup (GetHelpContent("m_ShowType") , showType); // -------------------------------------------------------------- EditorGUILayout.Space(); NcSpriteFactory.SHOW_TYPE showType = (NcSpriteFactory.SHOW_TYPE)EditorPrefs.GetInt("NcSpriteFactory.SHOW_TYPE", 0); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 0, 1), showType == NcSpriteFactory.SHOW_TYPE.NONE, GetHelpContent("NONE"), true) ? NcSpriteFactory.SHOW_TYPE.NONE : showType; showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 1, 1), showType == NcSpriteFactory.SHOW_TYPE.ALL, GetHelpContent("ALL"), true) ? NcSpriteFactory.SHOW_TYPE.ALL : showType; if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 2, 1), showType == NcSpriteFactory.SHOW_TYPE.SPRITE, GetHelpContent("SPRITE"), true) ? NcSpriteFactory.SHOW_TYPE.SPRITE : showType; showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 3, 1), showType == NcSpriteFactory.SHOW_TYPE.ANIMATION, GetHelpContent("ANIMATION"), true) ? NcSpriteFactory.SHOW_TYPE.ANIMATION : showType; } showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 4, 1), showType == NcSpriteFactory.SHOW_TYPE.EFFECT, GetHelpContent("EFFECT"), true) ? NcSpriteFactory.SHOW_TYPE.EFFECT : showType; GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); EditorPrefs.SetInt("NcSpriteFactory.SHOW_TYPE", ((int)showType)); // Show Option ------------------------------------------------- EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { m_Sel.m_bShowEffect = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), m_Sel.m_bShowEffect, GetHelpContent("m_bShowEffect"), true); if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { m_Sel.m_bTestMode = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), m_Sel.m_bTestMode, GetHelpContent("m_bTestMode"), true); m_Sel.m_bSequenceMode = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), m_Sel.m_bSequenceMode, GetHelpContent("m_bSequenceMode"), true); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); // Node List ------------------------------------------------------ for (int n = 0; n < (spriteList != null ? spriteList.Count : 0); n++) { EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); // Load Texture --------------------------------------------------------- Texture2D selTexture = null; if (spriteList[n].m_TextureGUID != "") { selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(spriteList[n].m_TextureGUID), typeof(Texture2D)); } // Enabled -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { Rect subRect; EditorGUI.BeginChangeCheck(); // enable spriteList[n].m_bIncludedAtlas = GUILayout.Toggle(spriteList[n].m_bIncludedAtlas, "Idx", GUILayout.Width(nLeftWidth)); // change index subRect = rect; subRect.x += nLeftWidth; subRect.width = nLineHeight * 2; int newPos = EditorGUI.IntPopup(subRect, n, NgConvert.GetIntStrings(0, spriteList.Count), NgConvert.GetIntegers(0, spriteList.Count)); if (newPos != n) { NcSpriteFactory.NcSpriteNode node = spriteList[n]; m_Sel.m_SpriteList.Remove(node); m_Sel.m_SpriteList.Insert(newPos, node); return; } if (EditorGUI.EndChangeCheck()) { m_Sel.m_bNeedRebuild = true; } // name subRect = rect; subRect.x += nLeftWidth + nLineHeight * 2; subRect.width -= nLeftWidth + nLineHeight * 2; spriteList[n].m_TextureName = selTexture == null ? "" : selTexture.name; GUI.Label(subRect, (selTexture == null ? "" : "(" + spriteList[n].m_nFrameCount + ") " + selTexture.name)); GUI.Box(subRect, ""); GUI.Box(rect, ""); // delete if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Del"))) { m_Sel.m_bNeedRebuild = true; bClickButton = true; if (m_FxmPopupManager != null) { m_FxmPopupManager.CloseNcPrefabPopup(); } m_Sel.DeleteSpriteNode(n); return; } } EditorGUILayout.EndHorizontal(); // SpriteName MaxAlpha ----------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUILayout.Label("", GUILayout.Width(nLineHeight)); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 0, 2), "Name,fMaxAlpha"); spriteList[n].m_SpriteName = EditorGUI.TextField(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 2, 4), spriteList[n].m_SpriteName); spriteList[n].m_fMaxTextureAlpha = EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 7, 6, 1), spriteList[n].m_fMaxTextureAlpha); } EditorGUILayout.EndHorizontal(); // Texture -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nSpriteHeight / (selTexture == null ? 2 : 1))); { GUILayout.Label("", GUILayout.Width(nLeftWidth)); Rect subRect = rect; subRect.width = nLeftWidth; FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5); EditorGUI.BeginChangeCheck(); selTexture = (Texture2D)EditorGUI.ObjectField(subRect, GetHelpContent(""), selTexture, typeof(Texture2D), false); if (EditorGUI.EndChangeCheck()) { if (selTexture != null) { spriteList[n].m_TextureGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selTexture)); } m_Sel.m_bNeedRebuild = true; } // draw texture subRect = FXMakerLayout.GetOffsetRect(rect, nLeftWidth + 4, 0, 0, -4); Rect drawRect = FXMakerLayout.GetOffsetRect(subRect, 0, 0, -nDelWidth, 0); if (selTexture != null) { // draw texture GUI.DrawTexture(drawRect, selTexture, ScaleMode.ScaleToFit, true, selTexture.width / selTexture.height); // draw tile float fDrawRatio = drawRect.width / drawRect.height; float fImageRatio = selTexture.width / selTexture.height; if (fDrawRatio < fImageRatio) { drawRect = FXMakerLayout.GetVOffsetRect(drawRect, drawRect.height * -(1 - (fDrawRatio / fImageRatio)) / 2); } else { drawRect = FXMakerLayout.GetHOffsetRect(drawRect, drawRect.width * -(1 - (fImageRatio / fDrawRatio)) / 2); } float tileWidth = (drawRect.width / spriteList[n].m_nTilingX); float tileHeight = (drawRect.height / spriteList[n].m_nTilingY); for (int tn = spriteList[n].m_nStartFrame; tn < Mathf.Min(spriteList[n].m_nStartFrame + spriteList[n].m_nFrameCount, spriteList[n].m_nTilingX * spriteList[n].m_nTilingY); tn++) { int posx = tn % spriteList[n].m_nTilingX; int posy = tn / spriteList[n].m_nTilingX; Rect tileRect = new Rect(drawRect.x + posx * tileWidth, drawRect.y + posy * tileHeight, tileWidth, tileHeight); NgGUIDraw.DrawBox(FXMakerLayout.GetOffsetRect(tileRect, -1), Color.green, 1, false); } } // delete if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Rmv"))) { spriteList[n].SetEmpty(); } GUI.Box(rect, ""); } EditorGUILayout.EndHorizontal(); // Change selIndex Event e = Event.current; if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition)) { nClickIndex = n; nClickButton = e.button; } // ----------------------------------------------------------------------------------------------------------------------------------------------- if (spriteList[n].IsEmptyTexture() == false) { // Frame tile rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUILayout.Label("", GUILayout.Width(nLineHeight)); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "nTileXY,Start,Count"); // m_nTilingX, m_nTilingY EditorGUI.BeginChangeCheck(); spriteList[n].m_nTilingX = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_nTilingX); spriteList[n].m_nTilingY = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 5, 1), spriteList[n].m_nTilingY); SetMinValue(ref spriteList[n].m_nTilingX, 1); SetMinValue(ref spriteList[n].m_nTilingY, 1); if (EditorGUI.EndChangeCheck()) { spriteList[n].m_nFrameCount = spriteList[n].m_nTilingX * spriteList[n].m_nTilingY - spriteList[n].m_nStartFrame; m_Sel.m_bNeedRebuild = true; } // m_nStartFrame, m_nFrameCount EditorGUI.BeginChangeCheck(); spriteList[n].m_nStartFrame = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 6, 1), spriteList[n].m_nStartFrame); spriteList[n].m_nFrameCount = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 7, 1), spriteList[n].m_nFrameCount); SetMaxValue(ref spriteList[n].m_nStartFrame, spriteList[n].m_nTilingX * spriteList[n].m_nTilingY - 1); SetMinValue(ref spriteList[n].m_nStartFrame, 0); SetMaxValue(ref spriteList[n].m_nFrameCount, spriteList[n].m_nTilingX * spriteList[n].m_nTilingY - spriteList[n].m_nStartFrame); SetMinValue(ref spriteList[n].m_nFrameCount, 1); if (EditorGUI.EndChangeCheck()) { m_Sel.m_bNeedRebuild = true; } } EditorGUILayout.EndHorizontal(); // SpriteNode ---------------------------------------------------------- if (bClickButton == false) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.SPRITE)) { rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUILayout.Label("", GUILayout.Width(nLineHeight)); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 0, 4), "Loop,Start,FCnt,LCnt"); bool bOldLoop = spriteList[n].m_bLoop; spriteList[n].m_bLoop = EditorGUI.Toggle(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 4, 1), spriteList[n].m_bLoop); if (!bOldLoop && spriteList[n].m_bLoop) { spriteList[n].m_nLoopStartFrame = 0; spriteList[n].m_nLoopFrameCount = spriteList[n].m_nFrameCount; spriteList[n].m_nLoopingCount = 0; } if (spriteList[n].m_bLoop) { spriteList[n].m_nLoopStartFrame = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 5, 1), spriteList[n].m_nLoopStartFrame); spriteList[n].m_nLoopFrameCount = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 6, 1), spriteList[n].m_nLoopFrameCount); spriteList[n].m_nLoopingCount = EditorGUI.IntField(FXMakerLayout.GetInnerHorizontalRect(rect, 8, 7, 1), spriteList[n].m_nLoopingCount); } // check SetMaxValue(ref spriteList[n].m_nLoopStartFrame, spriteList[n].m_nFrameCount - 1); SetMinValue(ref spriteList[n].m_nLoopStartFrame, 0); SetMaxValue(ref spriteList[n].m_nLoopFrameCount, spriteList[n].m_nFrameCount - spriteList[n].m_nLoopStartFrame); SetMinValue(ref spriteList[n].m_nLoopingCount, 0); } EditorGUILayout.EndHorizontal(); spriteList[n].m_fTime = EditorGUILayout.Slider(GetHelpContent("m_fTime"), spriteList[n].m_nFrameCount / spriteList[n].m_fFps, 0, 5, null); spriteList[n].m_fFps = EditorGUILayout.Slider(GetHelpContent("m_fFps"), spriteList[n].m_nFrameCount / spriteList[n].m_fTime, 50, 1, null); } if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.ANIMATION)) { spriteList[n].m_nNextSpriteIndex = EditorGUILayout.Popup("m_nNextSpriteIndex", spriteList[n].m_nNextSpriteIndex + 1, GetSpriteNodeNames()) - 1; if (0 <= spriteList[n].m_nNextSpriteIndex) { spriteList[n].m_nTestMode = EditorGUILayout.Popup("m_nTestMode", spriteList[n].m_nTestMode, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(FxmTestControls.AXIS.Z)), GUILayout.MaxWidth(Screen.width)); spriteList[n].m_fTestSpeed = EditorGUILayout.FloatField("m_fTestSpeed", spriteList[n].m_fTestSpeed); SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f); } } if (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.EFFECT) { EditorGUILayout.Separator(); // char effect ------------------------------------------------------------- spriteList[n].m_EffectPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_EffectPrefab"), spriteList[n].m_EffectPrefab, typeof(GameObject), false, null); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f)); { if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelEffect"), (m_FxmPopupManager != null))) { m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, n, 0, true); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearEffect"), (spriteList[n].m_EffectPrefab != null))) { bClickButton = true; spriteList[n].m_EffectPrefab = null; } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); if (spriteList[n].m_EffectPrefab != null) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { spriteList[n].m_nEffectFrame = EditorGUILayout.IntSlider(GetHelpContent("m_nEffectFrame"), spriteList[n].m_nEffectFrame, 0, spriteList[n].m_nFrameCount, null); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUILayout.Label("", GUILayout.Width(nLineHeight)); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), "bOnlyFirst,bEffDetach"); spriteList[n].m_bEffectOnlyFirst = EditorGUI.Toggle(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), spriteList[n].m_bEffectOnlyFirst); spriteList[n].m_bEffectDetach = EditorGUI.Toggle(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), spriteList[n].m_bEffectDetach); } EditorGUILayout.EndHorizontal(); } rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUILayout.Label("", GUILayout.Width(nLineHeight)); GUI.Label(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 0, 2), "fSpeed, fScale"); spriteList[n].m_fEffectSpeed = EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 2, 1), spriteList[n].m_fEffectSpeed); spriteList[n].m_fEffectScale = EditorGUI.FloatField(FXMakerLayout.GetInnerHorizontalRect(rect, 4, 3, 1), spriteList[n].m_fEffectScale); } EditorGUILayout.EndHorizontal(); spriteList[n].m_EffectPos = EditorGUILayout.Vector3Field("m_EffectPos", spriteList[n].m_EffectPos, null); spriteList[n].m_EffectRot = EditorGUILayout.Vector3Field("m_EffectRot", spriteList[n].m_EffectRot, null); SetMinValue(ref spriteList[n].m_fEffectScale, 0.001f); } EditorGUILayout.Space(); // char sound ------------------------------------------------------------- spriteList[n].m_AudioClip = (AudioClip)EditorGUILayout.ObjectField(GetHelpContent("m_AudioClip"), spriteList[n].m_AudioClip, typeof(AudioClip), false, null); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f)); { // if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelAudio"), (m_FxmPopupManager != null))) // m_FxmPopupManager.ShowSelectAudioClipPopup(m_Sel); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearAudio"), (spriteList[n].m_AudioClip != null))) { bClickButton = true; spriteList[n].m_AudioClip = null; } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); if (spriteList[n].m_AudioClip != null) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { spriteList[n].m_nSoundFrame = EditorGUILayout.IntSlider(GetHelpContent("m_nSoundFrame"), spriteList[n].m_nSoundFrame, 0, spriteList[n].m_nFrameCount, null); spriteList[n].m_bSoundOnlyFirst = EditorGUILayout.Toggle(GetHelpContent("m_bSoundOnlyFirst"), spriteList[n].m_bSoundOnlyFirst); } spriteList[n].m_bSoundLoop = EditorGUILayout.Toggle(GetHelpContent("m_bSoundLoop"), spriteList[n].m_bSoundLoop); spriteList[n].m_fSoundVolume = EditorGUILayout.Slider(GetHelpContent("m_fSoundVolume"), spriteList[n].m_fSoundVolume, 0, 1.0f, null); spriteList[n].m_fSoundPitch = EditorGUILayout.Slider(GetHelpContent("m_fSoundPitch"), spriteList[n].m_fSoundPitch, -3, 3.0f, null); } } } } if (EditorGUI.EndChangeCheck()) { nClickIndex = n; } selTexture = null; } // Select Node ---------------------------------------------------- if (0 <= nClickIndex) { m_Sel.SetSprite(nClickIndex, false); if (m_Sel.m_bTestMode && 0 <= spriteList[nClickIndex].m_nTestMode && GetFXMakerMain()) { GetFXMakerMain().GetFXMakerControls().SetTransIndex(spriteList[nClickIndex].m_nTestMode, (4 <= spriteList[nClickIndex].m_nTestMode ? 1.8f : 1.0f), spriteList[nClickIndex].m_fTestSpeed); } // Rotate if (nClickButton == 1) { m_Sel.transform.Rotate(0, 180, 0); } nClickIndex = -1; bClickButton = true; } m_UndoManager.CheckDirty(); } // -------------------------------------------------------------- if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain()) { OnEditComponent(); } // --------------------------------------------------------------------- if (GUI.tooltip != "") { m_LastTooltip = GUI.tooltip; } HelpBox(m_LastTooltip); }
public static Color GetMaterialColor(Material mat) { return(NgMaterial.GetMaterialColor(mat, Color.white)); }
public static bool IsSameMaterial(Material mat1, Material mat2, bool bCheckAddress) { return((!bCheckAddress || !(mat1 != mat2)) && !(mat2 == null) && !(mat1.shader != mat2.shader) && !(mat1.mainTexture != mat2.mainTexture) && !(mat1.mainTextureOffset != mat2.mainTextureOffset) && !(mat1.mainTextureScale != mat2.mainTextureScale) && NgMaterial.IsSameColorProperty(mat1, mat2, "_Color") && NgMaterial.IsSameColorProperty(mat1, mat2, "_TintColor") && NgMaterial.IsSameColorProperty(mat1, mat2, "_EmisColor") && NgMaterial.IsSameFloatProperty(mat1, mat2, "_InvFade") && NgMaterial.IsMaskTexture(mat1) == NgMaterial.IsMaskTexture(mat2) && (!NgMaterial.IsMaskTexture(mat1) || !(NgMaterial.GetMaskTexture(mat1) != NgMaterial.GetMaskTexture(mat2)))); }
void SaveMaterial(Material addMat) { string path = ""; string newPath = ""; string uniquePath; Object existsObj; int nUniqueCount = 0; // Find Same Material if (m_bUniqueSave == false && m_SelectedTextureMaterials != null) { foreach (Material mat in m_SelectedTextureMaterials) { if (NgMaterial.IsSameMaterial(mat, addMat, false)) { NgUtil.LogMessage(FXMakerTooltip.GetHsToolMessage("MATERIAL_EXISTSAVED", "")); SetSelectedTransformMaterial(mat); return; } } } // Create Path bool bUseDefaultFolder = false; string devMatDir = "_MaterialsTool"; string userMatDir = "_MaterialsUser"; string matDir; if (FXMakerLayout.m_bDevelopState) { matDir = devMatDir; } else { matDir = userMatDir; } if ((addMat.mainTexture != null)) { path = AssetDatabase.GetAssetPath(addMat.mainTexture); if (path == "") { bUseDefaultFolder = true; } else { newPath = NgFile.CombinePath(NgFile.TrimFilenameExt(path), matDir); // Default SubDirectory if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(NgFile.TrimFilenameExt(path), matDir); } } } else { newPath = NgFile.TrimFilenameExt(AssetDatabase.GetAssetPath(m_OriMaterial)); if (newPath == "") { bUseDefaultFolder = true; } else { string tmpPath = NgFile.TrimLastFolder(newPath); string tmpLast = NgFile.GetLastFolder(newPath); if (FXMakerLayout.m_bDevelopState) { if (tmpLast != devMatDir) { newPath = NgFile.CombinePath(tmpPath, devMatDir); if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(tmpPath, matDir); } } } else { if (tmpLast != userMatDir) { newPath = NgFile.CombinePath(tmpPath, userMatDir); if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(tmpPath, matDir); } } } } } if (bUseDefaultFolder) { path = FXMakerMain.inst.GetResourceDir(FXMakerMain.TOOLDIR_TYPE.BACKGROUNDRESOURCES); newPath = NgFile.CombinePath(path, matDir); // Default SubDirectory if (NgAsset.ExistsDirectory(newPath) == false) { AssetDatabase.CreateFolder(path, matDir); } } // Unique Name string texname = addMat.name; if (addMat.mainTexture != null) { texname = addMat.mainTexture.name; } int nLoopCount = 0; while (true) { string matName = texname + (0 < nUniqueCount ? "_" + nUniqueCount.ToString() : "") + ".mat"; uniquePath = NgFile.CombinePath(newPath, matName); existsObj = AssetDatabase.LoadAssetAtPath(uniquePath, typeof(Material)); if (existsObj == null) { break; } nLoopCount++; nUniqueCount++; if (999 < nUniqueCount) { nUniqueCount = 1; } if (999 < nLoopCount) { Debug.LogError("Over Loop ----------------------"); return; } } AssetDatabase.CreateAsset(addMat, uniquePath); NgUtil.LogMessage(FXMakerTooltip.GetHsToolMessage("MATERIAL_NEWSAVED", "") + "\n" + uniquePath); FXMakerAsset.AssetDatabaseRefresh(); FXMakerAsset.AssetDatabaseSaveAssets(); }
// ========================================================================================================== void winPopup(int id) { Rect baseRect = GetPopupRect(); Rect buttonRect; Rect lineRect; if (UnfocusClose(baseRect, -10, 0, 0, 0)) { return; } baseRect = FXMakerLayout.GetChildVerticalRect(baseRect, 0, 1, 0, 1); Transform transOriginalRoot = FXMakerMain.inst.GetOriginalEffectObject().transform; int nButtonCount = m_nButtonCount * 2; int nDrawCount = 0; bool bEnable = false; // Copy if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Copy"), true)) { FXMakerClipboard.inst.SetClipboardObject(m_SelectedObject); ClosePopup(true); return; } nDrawCount += 2; // Cut switch (m_SelObjectType) { case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT: bEnable = (m_SelectedTransform != transOriginalRoot); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP: bEnable = false; break; default: Debug.LogWarning("not declare"); break; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Cut"), bEnable)) { FXMakerClipboard.inst.SetClipboardObject(m_SelectedObject); FXMakerHierarchy.inst.DeleteHierarchyObject(m_SelectedTransform, m_SelectedObject, m_nSelectedIndex); ClosePopup(true); return; } nDrawCount += 2; // Paste switch (m_SelObjectType) { case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER: bEnable = FXMakerClipboard.inst.IsObject(); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP: bEnable = false; break; default: Debug.LogWarning("not declare"); break; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Paste", FXMakerClipboard.inst.GetName()), bEnable)) { Object tarObj = FXMakerClipboard.inst.PasteClipboardObject(m_SelectedTransform.gameObject, m_SelectedObject, m_nSelectedIndex); if (tarObj is GameObject) { SetAddObject((tarObj as GameObject), tarObj); } else { SetAddObject(null, tarObj); } ClosePopup(true); return; } nDrawCount += 2; // Overwrite switch (m_SelObjectType) { case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM: bEnable = FXMakerClipboard.inst.IsTransform() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType(); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER: bEnable = FXMakerClipboard.inst.IsComponent() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType(); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL: bEnable = FXMakerClipboard.inst.IsMaterial() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType(); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP: bEnable = FXMakerClipboard.inst.IsAnimationClip() && FXMakerClipboard.inst.GetObject().GetType() == m_SelectedObject.GetType(); break; default: Debug.LogWarning("not declare"); break; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Overwrite", FXMakerClipboard.inst.GetName()), bEnable)) { FXMakerClipboard.inst.OverwriteClipboardObject(m_SelectedTransform.gameObject, m_SelectedObject, m_nSelectedIndex); ClosePopup(true); return; } nDrawCount += 2; // Draw line lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 1); NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y + lineRect.height / 2), (int)lineRect.width, Color.gray, 2, false); nDrawCount += 1; // Duplicate switch (m_SelObjectType) { case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT: bEnable = (m_SelectedTransform != transOriginalRoot); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP: bEnable = false; break; default: Debug.LogWarning("not declare"); break; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Duplicate"), bEnable)) { switch (m_SelObjectType) { case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT: SetAddObject(FXMakerHierarchy.inst.AddGameObject(m_SelectedTransform.transform.parent.gameObject, m_SelectedTransform.gameObject), null); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM: break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE: case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER: m_AddComObject = NgSerialized.CloneComponent(m_SelectedObject as Component, (m_SelectedObject as Component).gameObject, false); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL: break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP: break; default: Debug.LogWarning("not declare"); break; } ClosePopup(true); return; } nDrawCount += 2; // Disable if (m_SelObjectType == FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT) { bool bObjEnable = (m_SelectedTransform.gameObject.GetComponent <NcDontActive>() == null); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), (bObjEnable ? GetHelpContent("Disable") : GetHelpContent("Enable")), (m_SelectedTransform != transOriginalRoot))) { FXMakerHierarchy.inst.SetEnableGameObject(m_SelectedTransform.gameObject, !bObjEnable); ClosePopup(true); return; } } else { buttonRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2); if (m_SelectedObject is Component) { int nObjEnable = EditorUtility.GetObjectEnabled(m_SelectedObject); if (0 <= nObjEnable) { if (0 < nObjEnable) { if (GUI.Button(buttonRect, GetHelpContent("Disable"))) { EditorUtility.SetObjectEnabled(m_SelectedObject, false); ClosePopup(true); return; } } else { if (GUI.Button(buttonRect, GetHelpContent("Enable"))) { EditorUtility.SetObjectEnabled(m_SelectedObject, true); ClosePopup(true); return; } } } else { FXMakerLayout.GUIButton(buttonRect, GetHelpContent("Disable"), false); } } else { FXMakerLayout.GUIButton(buttonRect, GetHelpContent("Disable"), false); } } nDrawCount += 2; // Delete switch (m_SelObjectType) { case FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT: bEnable = (m_SelectedTransform != transOriginalRoot); break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_TRANSFORM: bEnable = false; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_EASYEFFECT: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_UNITYENGINE: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_OTHER: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL: bEnable = true; break; case FXMakerHierarchy.OBJECT_TYPE.OBJECT_ANICLIP: bEnable = true; break; default: Debug.LogWarning("not declare"); break; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Delete"), bEnable)) { FXMakerHierarchy.inst.DeleteHierarchyObject(m_SelectedTransform, m_SelectedObject, m_nSelectedIndex); ClosePopup(true); return; } nDrawCount += 2; // Draw line lineRect = FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 1); NgGUIDraw.DrawHorizontalLine(new Vector2(lineRect.x, lineRect.y + lineRect.height / 2), (int)lineRect.width, Color.gray, 2, false); nDrawCount += 1; // ------------------------------------------------------------------------------------- if (m_SelectedObject is NcCurveAnimation) { // NcCurveAnimation NcCurveAnimation curveCom = m_SelectedObject as NcCurveAnimation; if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("SaveCurves"), 0 < curveCom.GetCurveInfoCount())) { ClosePopup(true); FxmPopupManager.inst.ShowNcCurveAnimationPopup(curveCom, true); return; } nDrawCount += 2; if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("LoadCurves"), true)) { ClosePopup(true); FxmPopupManager.inst.ShowNcCurveAnimationPopup(curveCom, false); return; } nDrawCount += 2; } // ------------------------------------------------------------------------------------- if (m_SelObjectType == FXMakerHierarchy.OBJECT_TYPE.OBJECT_GAMEOBJECT) { // Add Child if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Child"), true)) { // GameObject newChild = new GameObject("GameObject"); // newChild.transform.parent = m_SelectedTransform; // FXMakerHierarchy.inst.OnAddGameObject(newChild); // SetAddObject(newChild, null); // ClosePopup(true); FXMakerHierarchy.inst.ShowAddObjectRightPopup(); ClosePopup(false); return; } nDrawCount += 2; // Add Parent if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Parent"), true)) { GameObject newParent = new GameObject("GameObject"); newParent.transform.parent = m_SelectedTransform.parent; m_SelectedTransform.parent = newParent.transform; m_SelectedTransform.name = m_SelectedTransform.name.Replace("(Original)", ""); if (m_SelectedTransform == transOriginalRoot) { FXMakerMain.inst.ChangeRoot_OriginalEffectObject(newParent); } FXMakerHierarchy.inst.OnAddGameObject(newParent); SetAddObject(newParent, null); ClosePopup(true); return; } nDrawCount += 2; // MoveToParent if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("MoveToParent"), (m_SelectedTransform != transOriginalRoot && (m_SelectedTransform.parent != transOriginalRoot) || (m_SelectedTransform.parent == transOriginalRoot && transOriginalRoot.childCount == 1)))) { if (m_SelectedTransform.parent == transOriginalRoot && transOriginalRoot.childCount == 1) { FXMakerMain.inst.SaveTool(""); m_SelectedTransform = FXMakerMain.inst.GetOriginalEffectObject().transform; // root swap Transform toolRoot = m_SelectedTransform.parent; Transform newParent = m_SelectedTransform.GetChild(0); Transform newChild = m_SelectedTransform; newChild.parent = null; newParent.parent = null; newChild.parent = newParent; newParent.parent = toolRoot; m_SelectedTransform = newParent; FXMakerMain.inst.ChangeRoot_OriginalEffectObject(m_SelectedTransform.gameObject); SetAddObject(null, null); } else { m_SelectedTransform.parent = m_SelectedTransform.parent.parent; } ClosePopup(true); return; } nDrawCount += 2; // Add Component if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Component"), true)) { ClosePopup(true); FxmPopupManager.inst.ShowHierarchyObjectPopup("FxmPopup_GameObject", m_SelectedTransform.gameObject); return; } nDrawCount += 2; // Add Prefab if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Add Prefab"), true)) { FxmPopupManager.inst.ShowAddPrefabPopup(m_SelectedTransform); ClosePopup(true); return; } nDrawCount += 2; // Save Prefab if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Save Prefab"), true)) { ClosePopup(true); FxmPopupManager.inst.ShowSavePrefabPopup(m_SelectedTransform); return; } nDrawCount += 2; } // ------------------------------------------------------------------------------------- if (m_SelObjectType == FXMakerHierarchy.OBJECT_TYPE.OBJECT_MATERIAL) { bEnable = NgMaterial.IsMaterialColor(m_SelectedObject as Material); // Copy Color if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Copy Color"), bEnable)) { FXMakerClipboard.inst.SetClipboardColor(NgMaterial.GetMaterialColor(m_SelectedObject as Material)); ClosePopup(true); return; } if (bEnable) { Rect colorRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), -5); colorRect.width = colorRect.height; EditorGUIUtility.DrawColorSwatch(colorRect, NgMaterial.GetMaterialColor(m_SelectedObject as Material)); } nDrawCount += 2; // Paste Color if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), GetHelpContent("Paste Color"), bEnable)) { FXMakerClipboard.inst.PasteClipboardColor(m_SelectedTransform, m_nSelectedIndex, m_SelectedObject as Material); ClosePopup(true); return; } { Rect colorRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(baseRect, nButtonCount, nDrawCount, 2), -5); colorRect.width = colorRect.height; EditorGUIUtility.DrawColorSwatch(colorRect, FXMakerClipboard.inst.m_CopyColor); } nDrawCount += 2; } m_nButtonCount = nDrawCount / 2; FXMakerMain.inst.SaveTooltip(); }
void DrawBottomPaletteRect(Rect baseRect) { if (m_SelectedMaterial == null) { return; } GUIStyle styleBox = GUI.skin.GetStyle("MaterialList_Box"); Color oldColor = GUI.color; Color oldMatColor; bool bReinstance = false; if (NgMaterial.IsMaterialColor(m_SelectedMaterial) == false) { return; } // Color Palette Image baseRect = FXMakerLayout.GetOffsetRect(baseRect, 0, -2, 0, -3); GUI.Box(baseRect, FXMakerTooltip.GetGUIContentNoTooltip(), styleBox); baseRect = FXMakerLayout.GetOffsetRect(baseRect, 2, 2, -2, -2); Rect popupRect = GetPopupRect(); Rect leftRect = FXMakerLayout.GetInnerHorizontalRect(baseRect, 2, 0, 1); Rect rightRect = FXMakerLayout.GetInnerHorizontalRect(baseRect, 2, 1, 1); // Pickup Color GUI.color = Color.white; Color pickColor = oldMatColor = NgMaterial.GetMaterialColor(m_SelectedMaterial); Color32 oldMatCol32 = oldMatColor; // Color Progress Rect barRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(leftRect, 5, 0, 1), -1, 1, 1, -1); GUI.DrawTexture(FXMakerLayout.GetOffsetRect(barRect, 5, 0, -5, 0), m_PaletteBarColorImage); float fPaletteBarValue = GUI.HorizontalSlider(barRect, m_fPaletteBarColorValue, 0, 1.0f); if (m_fPaletteBarColorValue != fPaletteBarValue) { m_fPaletteBarColorValue = fPaletteBarValue; pickColor = m_PaletteBarColorImage.GetPixelBilinear(m_fPaletteBarColorValue, 0.5f); } // Color Palette Rect palRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(leftRect, 5, 1, 4), 4, 0, -4, -1); Rect lockRect = new Rect(palRect.x + popupRect.x, palRect.y + popupRect.y, palRect.width, palRect.height + 1); Vector2 mousePos = FXMakerLayout.GetGUIMousePosition(); GUI.DrawTexture(palRect, m_PalettePanelImage); if (Input.GetMouseButtonDown(0) && lockRect.Contains(mousePos)) { m_bEnterPalette = true; } if (Input.GetMouseButtonUp(0) && m_bEnterPalette) { m_bEnterPalette = false; bReinstance = true; } if (Input.GetMouseButton(0) && m_bEnterPalette) { int xpos = (int)(mousePos.x - lockRect.x); int ypos = (int)(mousePos.y - lockRect.y); if (xpos < 0) { xpos = 0; } if (ypos < 0) { ypos = 0; } if (lockRect.width <= xpos) { xpos = (int)(lockRect.width); } if (lockRect.height <= ypos) { ypos = (int)(lockRect.height); } pickColor = m_PalettePanelImage.GetPixelBilinear(xpos / palRect.width, (palRect.height - ypos) / palRect.height); } // Gray Progress GUI.changed = false; barRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(rightRect, 5, 0, 1), -1, 1, 1, -1); GUI.DrawTexture(FXMakerLayout.GetOffsetRect(barRect, 5, 0, -5, 0), m_PaletteBarGrayImage); fPaletteBarValue = GUI.HorizontalSlider(barRect, m_fPaletteBarGrayValue, 0, 1.0f); if (GUI.changed) // m_fPaletteBarGrayValue != fPaletteBarValue { m_fPaletteBarGrayValue = fPaletteBarValue; pickColor = m_PaletteBarGrayImage.GetPixelBilinear(m_fPaletteBarGrayValue, 0.5f); if (Input.GetMouseButtonDown(1)) { m_fPaletteBarGrayValue = 0.5f; pickColor = new Color(0.5f, 0.5f, 0.5f); } GUI.changed = false; } GUI.color = oldColor; // Color RGB Scroll rightRect = FXMakerLayout.GetOffsetRect(rightRect, 0, 3, -5, -3); Color32 selColor32 = new Color(pickColor.r, pickColor.g, pickColor.b, oldMatColor.a); int nTextWidth = 15; int nEditWidth = 38; string[] rgbName = { "R", "G", "B", "A" }; Color[] rgbColor = { Color.red, Color.green, Color.blue, Color.white }; byte[] RGBA = new byte[4]; RGBA[0] = selColor32.r; RGBA[1] = selColor32.g; RGBA[2] = selColor32.b; RGBA[3] = selColor32.a; // RGB Progress for (int n = 0; n < 4; n++) { string str; oldColor = GUI.color; Rect line = FXMakerLayout.GetInnerVerticalRect(rightRect, 5, n + 1, 1); line.width = nTextWidth; GUI.color = rgbColor[n]; GUI.Label(line, rgbName[n]); GUI.color = oldColor; line = FXMakerLayout.GetInnerVerticalRect(rightRect, 5, n + 1, 1); RGBA[n] = (byte)GUI.HorizontalSlider(FXMakerLayout.GetOffsetRect(line, nTextWidth, 0, -nEditWidth - 8, 0), RGBA[n], 0, 255); if (GUI.changed) { if (Input.GetMouseButtonDown(1)) { RGBA[n] = 127; } GUI.changed = false; } line.x = line.x + line.width - nEditWidth; line.width = nEditWidth; str = GUI.TextField(FXMakerLayout.GetOffsetRect(line, 0, -2, 0, 2), RGBA[n].ToString()); RGBA[n] = (byte)(255 < NgConvert.ToUint(str, RGBA[n]) ? 255 : NgConvert.ToUint(str, RGBA[n])); } selColor32.r = RGBA[0]; selColor32.g = RGBA[1]; selColor32.b = RGBA[2]; selColor32.a = RGBA[3]; if (selColor32.r != oldMatCol32.r || selColor32.g != oldMatCol32.g || selColor32.b != oldMatCol32.b || selColor32.a != oldMatCol32.a) { SetActiveMaterialColor(selColor32); } // mouse up - reinstance Rect chkRect = new Rect(baseRect.x + popupRect.x, baseRect.y + popupRect.y, baseRect.width, baseRect.height); if (Input.GetMouseButtonUp(0) && chkRect.Contains(mousePos)) { bReinstance = true; } if (bReinstance) { // CreateNewShaderMaterials(m_SelectedMaterial); FXMakerMain.inst.CreateCurrentInstanceEffect(true); } }
void DrawBottomMenuRect(Rect baseRect) { GUI.Box(baseRect, ""); Rect imageRect = baseRect; imageRect.width = m_nOriginalBottomHeight - 1; Rect rightRect = baseRect; rightRect.x += imageRect.width; rightRect.width -= imageRect.width; rightRect = FXMakerLayout.GetOffsetRect(rightRect, 5, 3, -5, -3); Rect buttonRect = FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 0, 5); int nButtonWidht = 70; buttonRect.width = nButtonWidht / 2; if (m_SelectedMaterial != null && m_SelObjectContent != null) { // image if (GUI.Button(imageRect, new GUIContent("", m_SelObjectContent.image, m_SelObjectContent.tooltip), GUI.skin.GetStyle("PopupBottom_ImageButton"))) { if (Input.GetMouseButtonUp(0)) { if (0 <= m_nNewShaderMaterialIndex) { FXMakerAsset.SetPingObject(m_SelectedTransform.gameObject); } else { FXMakerAsset.SetPingObject(m_SelectedMaterial); } FXMakerMain.inst.CreateCurrentInstanceEffect(true); } if (Input.GetMouseButtonUp(1)) { FXMakerAsset.SetPingObject(m_SelObjectContent.image); } } // Current Color Color matColor = NgMaterial.GetMaterialColor(m_SelectedMaterial); Rect colorRect = FXMakerLayout.GetOffsetRect(FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 5, 7), 0, 2, 0, 0); colorRect.width = nButtonWidht / 2; if (NgMaterial.IsMaterialColor(m_SelectedMaterial)) { EditorGUIUtility.DrawColorSwatch(colorRect, matColor); } // text rightRect.x += colorRect.width; rightRect.width -= colorRect.width; GUI.Label(FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 5, 3), m_SelObjectContent.text); GUI.Label(FXMakerLayout.GetInnerVerticalRect(rightRect, 12, 7, 5), (m_SelectedMaterial.shader != null ? m_SelectedMaterial.shader.name : "[Not Selected]")); bool bChange = (NgMaterial.IsSameMaterial(m_SelectedMaterial, m_OriMaterial, true) == false); // Undo if (FXMakerLayout.GUIButton(buttonRect, GetHelpContent("Undo"), bChange)) { UndoObject(); return; } // UniqueSave buttonRect.x += buttonRect.width + 5; buttonRect.width = nButtonWidht; if (FXMakerLayout.GUIButton(buttonRect, GetHelpContent("UniqueSave"), bChange)) { m_bUniqueSave = true; ClosePopup(true); return; } } // close buttonRect.x += buttonRect.width + 5; buttonRect.width = baseRect.width - buttonRect.x; if (GUI.Button(buttonRect, GetHelpContent("Close"))) { ClosePopup(true); } // ���õȰ�, ������, ��ġ, ȸ��, ����, �ݱ�, ��� }
void DrawBottomMaterialRect(Rect baseRect) { int nVMargin = 4; GUIStyle styleBox = GUI.skin.GetStyle("MaterialList_Box"); GUIStyle styleButton = GUI.skin.GetStyle("ImageOnly_Button"); // Draw line NgGUIDraw.DrawHorizontalLine(new Vector2(baseRect.x + nVMargin, baseRect.y + nVMargin), (int)baseRect.width, new Color(0.1f, 0.1f, 0.1f, 0.7f), 2, false); baseRect = FXMakerLayout.GetOffsetRect(baseRect, 0, nVMargin * 2, 0, -nVMargin); int nObjectCount; Rect listRect; int nColumn; Rect scrollRect; Rect gridRect; int nSelectIndex; bool bShowList = true; // (0 <= m_nObjectIndex && m_nSelObjectProjectIndex == m_nProjectIndex && m_nGroupIndex == m_nSelObjectGroupIndex); // New Shader Material List ------------------------------------------------------ listRect = FXMakerLayout.GetInnerHorizontalRect(baseRect, 2, 0, 1); GUI.Box(listRect, GetHelpContent("New Shader Material"), styleBox); if (bShowList && m_NewShaderMaterials != null && 0 < m_NewShaderMaterials.Length) { listRect = FXMakerLayout.GetOffsetRect(listRect, 5, 15, -5, -3); nColumn = (int)((listRect.width - 5) / listRect.height * 2.3f); nObjectCount = m_NewShaderMaterials.Length; scrollRect = FXMakerLayout.GetAspectScrollViewRect((int)listRect.width, m_fButtonAspect, nObjectCount, nColumn, true); gridRect = FXMakerLayout.GetAspectScrollGridRect((int)listRect.width, m_fButtonAspect, nObjectCount, nColumn, true); m_NewShaderMaterialListScrollPos = GUI.BeginScrollView(listRect, m_NewShaderMaterialListScrollPos, scrollRect); // nSelectIndex = GUI.SelectionGrid(gridRect, m_nNewShaderMaterialIndex, m_NewShaderMaterialContents, nColumn, styleButton); nSelectIndex = FXMakerLayout.TooltipSelectionGrid(FXMakerLayout.GetOffsetRect(GetPopupRect(), 0, -m_NewShaderMaterialListScrollPos.y), listRect, gridRect, m_nNewShaderMaterialIndex, m_NewShaderMaterialContents, nColumn, styleButton); if (m_nNewShaderMaterialIndex != nSelectIndex) { if (Input.GetMouseButtonUp(1)) { FXMakerAsset.SetPingObject(m_NewShaderMaterials[nSelectIndex]); } else { m_nNewShaderMaterialIndex = nSelectIndex; if (m_SelectedMaterial != null) { NgMaterial.CopyMaterialArgument(m_SelectedMaterial, m_NewShaderMaterials[nSelectIndex]); } SetActiveMaterial(m_NewShaderMaterials[nSelectIndex], null, true, false); } } GUI.EndScrollView(); } // Found Material List ------------------------------------------------------ listRect = FXMakerLayout.GetInnerHorizontalRect(baseRect, 2, 1, 1); GUI.Box(listRect, GetHelpContent("Found Material"), styleBox); if (bShowList && m_CurrentTextureMaterials != null && 0 < m_CurrentTextureMaterials.Length) { listRect = FXMakerLayout.GetOffsetRect(listRect, 5, 15, -5, -3); nColumn = (int)((listRect.width - 5) / listRect.height * 2.3f); nObjectCount = m_CurrentTextureMaterials.Length; scrollRect = FXMakerLayout.GetAspectScrollViewRect((int)listRect.width, m_fButtonAspect, nObjectCount, nColumn, true); gridRect = FXMakerLayout.GetAspectScrollGridRect((int)listRect.width, m_fButtonAspect, nObjectCount, nColumn, true); m_CurrentTextureMaterialListScrollPos = GUI.BeginScrollView(listRect, m_CurrentTextureMaterialListScrollPos, scrollRect); // nSelectIndex = GUI.SelectionGrid(gridRect, m_nCurrentTextureMaterialIndex, m_CurrentTextureMaterialContents, nColumn, styleButton); nSelectIndex = FXMakerLayout.TooltipSelectionGrid(FXMakerLayout.GetOffsetRect(GetPopupRect(), 0, -m_CurrentTextureMaterialListScrollPos.y), listRect, gridRect, m_nCurrentTextureMaterialIndex, m_CurrentTextureMaterialContents, nColumn, styleButton); if (m_nCurrentTextureMaterialIndex != nSelectIndex) { if (Input.GetMouseButtonUp(1)) { FXMakerAsset.SetPingObject(m_NewShaderMaterials[nSelectIndex]); } else { m_nCurrentTextureMaterialIndex = nSelectIndex; SetActiveMaterial(m_CurrentTextureMaterials[nSelectIndex], null, false, false); } } GUI.EndScrollView(); } }
public override void OnInspectorGUI() { AddScriptNameField(m_Sel); Rect rect; int nLeftWidth = 115; int nAddHeight = 22; int nDelHeight = 17; int nLineHeight = 19; int nCurveHeight = 50; List <NcCurveAnimation.NcInfoCurve> curveInfoList = m_Sel.m_CurveInfoList; m_FxmPopupManager = GetFxmPopupManager(); // test code // if (GUILayout.Button("Pause")) // FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcCurveAnimation>().PauseAnimation(); // if (GUILayout.Button("Resume")) // FxmInfoIndexing.FindInstanceIndexing(m_Sel.transform, false).GetComponent<NcCurveAnimation>().ResumeAnimation(); // -------------------------------------------------------------- bool bClickButton = false; EditorGUI.BeginChangeCheck(); { m_UndoManager.CheckUndo(); // -------------------------------------------------------------- m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag); EditorGUILayout.Space(); m_Sel.m_fDelayTime = EditorGUILayout.FloatField(GetHelpContent("m_fDelayTime"), m_Sel.m_fDelayTime); m_Sel.m_fDurationTime = EditorGUILayout.FloatField(GetHelpContent("m_fDurationTime"), m_Sel.m_fDurationTime); m_Sel.m_bAutoDestruct = EditorGUILayout.Toggle(GetHelpContent("m_bAutoDestruct"), m_Sel.m_bAutoDestruct); // check SetMinValue(ref m_Sel.m_fDelayTime, 0); SetMinValue(ref m_Sel.m_fDurationTime, 0.01f); // -------------------------------------------------------------- EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight * 3)); { if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetCurveInfoCount()))) { bClickButton = true; m_Sel.ClearAllCurveInfo(); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), 2, 0, 1), GetHelpContent("Load Curves"), (m_FxmPopupManager != null))) { m_FxmPopupManager.ShowNcCurveAnimationPopup(m_Sel, false); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1), 2, 1, 1), GetHelpContent("Save Curves"), (m_FxmPopupManager != null && 0 < m_Sel.GetCurveInfoCount()))) { m_FxmPopupManager.ShowNcCurveAnimationPopup(m_Sel, true); } if (GUI.Button(FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1), GetHelpContent("Add EmptyCurve"))) { bClickButton = true; m_Sel.AddCurveInfo(); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); m_UndoManager.CheckDirty(); // -------------------------------------------------------------- for (int n = 0; n < (curveInfoList != null ? curveInfoList.Count : 0); n++) { EditorGUILayout.Space(); // Enabled -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nDelHeight)); { GUI.Box(rect, ""); curveInfoList[n].m_bEnabled = GUILayout.Toggle(curveInfoList[n].m_bEnabled, "CurveInfo " + n.ToString(), GUILayout.Width(nLeftWidth)); // GUILayout.Label("CurveInfo Index " + n.ToString(), GUILayout.Width(nLeftWidth)); } EditorGUILayout.EndHorizontal(); // CurveName ----------------------------------------------------------- curveInfoList[n].m_CurveName = EditorGUILayout.TextField(GetHelpContent("m_CurveName"), curveInfoList[n].m_CurveName); // ApplyType -------------------------------------------------------------- EditorGUI.BeginChangeCheck(); { rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUI.Box(rect, ""); GUILayout.Label("", GUILayout.Width(nLeftWidth)); NcCurveAnimation.NcInfoCurve.APPLY_TYPE nApplyType = (NcCurveAnimation.NcInfoCurve.APPLY_TYPE)EditorGUI.Popup(new Rect(rect.x, rect.y, nLeftWidth, rect.height), (int)curveInfoList[n].m_ApplyType, NcCurveAnimation.NcInfoCurve.m_TypeName); if (curveInfoList[n].m_ApplyType != nApplyType) { curveInfoList[n].m_ApplyType = nApplyType; curveInfoList[n].SetDefaultValueScale(); } // Add Component bool bShowOption = true; if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.TEXTUREUV) { if (m_Sel.gameObject.GetComponent <NcUvAnimation>() == null) { bShowOption = false; FXMakerLayout.GUIColorBackup(FXMakerLayout.m_ColorHelpBox); if (GUI.Button(new Rect(rect.x + nLeftWidth, rect.y, rect.width - nLeftWidth, rect.height), GetHelpContent("Add NcUvAnimation Script"))) { m_Sel.gameObject.AddComponent <NcUvAnimation>(); } FXMakerLayout.GUIColorRestore(); } } if (bShowOption) { for (int nValueIndex = 0; nValueIndex < curveInfoList[n].GetValueCount(); nValueIndex++) { curveInfoList[n].m_bApplyOption[nValueIndex] = GUILayout.Toggle(curveInfoList[n].m_bApplyOption[nValueIndex], curveInfoList[n].GetValueName(nValueIndex)); } } if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE) { GUILayout.Label("LocalSpace"); } } EditorGUILayout.EndHorizontal(); } if (EditorGUI.EndChangeCheck()) { m_Sel.CheckInvalidOption(n); } if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MATERIAL_COLOR) { // ValueScale -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight * 2)); { GUI.Box(rect, ""); GUILayout.Label("", GUILayout.Width(nLeftWidth)); bool bEnableColor = (m_Sel.GetComponent <Renderer>() != null && m_Sel.GetComponent <Renderer>().sharedMaterial != null & NgMaterial.IsMaterialColor(m_Sel.GetComponent <Renderer>().sharedMaterial)); Rect colorRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1); colorRect.width = nLeftWidth; if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 0, 1), GetHelpContent("White"), bEnableColor)) { curveInfoList[n].m_ToColor = Color.white; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 1, 1), GetHelpContent("Current"), bEnableColor)) { curveInfoList[n].m_ToColor = NgMaterial.GetMaterialColor(m_Sel.GetComponent <Renderer>().sharedMaterial); } colorRect.x += colorRect.width; GUI.Label(colorRect, GetHelpContent("ToColor")); colorRect.x += 60; colorRect.width = rect.width - colorRect.x; curveInfoList[n].m_ToColor = EditorGUI.ColorField(colorRect, curveInfoList[n].m_ToColor); // m_bRecursively Rect recRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1); curveInfoList[n].m_bRecursively = GUI.Toggle(FXMakerLayout.GetRightRect(recRect, rect.width - nLeftWidth), curveInfoList[n].m_bRecursively, GetHelpContent("Recursively")); } EditorGUILayout.EndHorizontal(); } else if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.MESH_COLOR) { // ValueScale -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight * 3)); { GUI.Box(rect, ""); GUILayout.Label("", GUILayout.Width(nLeftWidth)); // bool bEnableColor = (m_Sel.renderer != null && m_Sel.renderer.sharedMaterial != null & NgMaterial.IsMaterialColor(m_Sel.renderer.sharedMaterial)); // From Color Rect colorRect = FXMakerLayout.GetInnerVerticalRect(rect, 3, 0, 1); colorRect.width = nLeftWidth; if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 0, 1), GetHelpContent("White"), true)) { curveInfoList[n].m_FromColor = Color.white; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 1, 1), GetHelpContent("Black"), true)) { curveInfoList[n].m_FromColor = Color.black; } colorRect.x += colorRect.width; GUI.Label(colorRect, GetHelpContent("FromColor")); colorRect.x += 60; colorRect.width = rect.width - colorRect.x; curveInfoList[n].m_FromColor = EditorGUI.ColorField(colorRect, curveInfoList[n].m_FromColor); // To Color colorRect = FXMakerLayout.GetInnerVerticalRect(rect, 3, 1, 1); colorRect.width = nLeftWidth; if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 0, 1), GetHelpContent("White"), true)) { curveInfoList[n].m_ToColor = Color.white; } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(colorRect, 2, 1, 1), GetHelpContent("Black"), true)) { curveInfoList[n].m_ToColor = Color.black; } colorRect.x += colorRect.width; GUI.Label(colorRect, GetHelpContent("ToColor")); colorRect.x += 60; colorRect.width = rect.width - colorRect.x; curveInfoList[n].m_ToColor = EditorGUI.ColorField(colorRect, curveInfoList[n].m_ToColor); // m_bRecursively Rect recRect = FXMakerLayout.GetInnerVerticalRect(rect, 3, 2, 1); curveInfoList[n].m_bRecursively = GUI.Toggle(FXMakerLayout.GetRightRect(recRect, rect.width - nLeftWidth), curveInfoList[n].m_bRecursively, GetHelpContent("Recursively")); } EditorGUILayout.EndHorizontal(); } else { // ValueScale -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { GUI.Box(rect, ""); GUILayout.Label("", GUILayout.Width(nLeftWidth)); if (curveInfoList[n].m_ApplyType == NcCurveAnimation.NcInfoCurve.APPLY_TYPE.SCALE) { curveInfoList[n].m_fValueScale = EditorGUI.FloatField(rect, GetHelpContent("Value Scale"), curveInfoList[n].m_fValueScale + 1) - 1; } else { curveInfoList[n].m_fValueScale = EditorGUI.FloatField(rect, GetHelpContent("Value Scale"), curveInfoList[n].m_fValueScale); } } EditorGUILayout.EndHorizontal(); } // Curve -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nCurveHeight)); { GUI.Box(rect, ""); GUILayout.Label("", GUILayout.Width(nLeftWidth)); EditorGUI.BeginChangeCheck(); { curveInfoList[n].m_AniCurve = EditorGUI.CurveField(FXMakerLayout.GetOffsetRect(rect, nLeftWidth + 4, 0, 0, -4), curveInfoList[n].m_AniCurve, Color.green, curveInfoList[n].GetEditRange()); // curveInfoList[n].m_AniCurve = EditorGUILayout.CurveField(" ", curveInfoList[n].m_AniCurve, Color.green, curveInfoList[n].GetEditRange(), GUILayout.Height(nCurveHeight-4)); // curveInfoList[n].m_AniCurve = EditorGUILayout.CurveField(" ", curveInfoList[n].m_AniCurve, GUILayout.Height(nCurveHeight-4)); } if (EditorGUI.EndChangeCheck()) { curveInfoList[n].NormalizeCurveTime(); } Rect buttonRect = rect; buttonRect.width = nLeftWidth; FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5); if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 1, 1), 2, 0, 2), GetHelpContent("Delete"))) { bClickButton = true; m_Sel.DeleteCurveInfo(n); } // if (m_FxmPopupManager != null) //{ // Rect buttonRect = rect; // buttonRect.width = nLeftWidth; // FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5); // if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 0, 1), 2, 0, 1), GetHelpContent("Change"))) // m_FxmPopupManager.ShowNcInfoCurvePopup(m_Sel, n, false); // if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 0, 1), 2, 1, 1), GetHelpContent("Save"))) // m_FxmPopupManager.ShowNcInfoCurvePopup(m_Sel, n, true); // if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(FXMakerLayout.GetInnerVerticalRect(buttonRect, 2, 1, 1), 2, 0, 2), GetHelpContent("Delete"))) // { // bClickButton = true; // m_Sel.DeleteCurveInfo(n); // } //} } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } } // -------------------------------------------------------------- if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain()) { OnEditComponent(); } // --------------------------------------------------------------------- if (GUI.tooltip != "") { m_LastTooltip = GUI.tooltip; } HelpBox(m_LastTooltip); }
public override void OnInspectorGUI() { AddScriptNameField(m_Sel); int nClickIndex = -1; int nClickButton = 0; Rect rect; int nLeftWidth = 35; int nAddHeight = 30; int nDelWidth = 35; int nLineHeight = 18; int nSpriteHeight = nLeftWidth; List <NcSpriteFactory.NcSpriteNode> spriteList = m_Sel.m_SpriteList; m_FxmPopupManager = GetFxmPopupManager(); // -------------------------------------------------------------- bool bClickButton = false; EditorGUI.BeginChangeCheck(); { m_UndoManager.CheckUndo(); // -------------------------------------------------------------- m_Sel.m_fUserTag = EditorGUILayout.FloatField(GetCommonContent("m_fUserTag"), m_Sel.m_fUserTag); EditorGUILayout.Space(); m_Sel.m_SpriteType = (NcSpriteFactory.SPRITE_TYPE)EditorGUILayout.EnumPopup(GetHelpContent("m_SpriteType"), m_Sel.m_SpriteType); // -------------------------------------------------------------- if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && m_Sel.gameObject.GetComponent("NcSpriteAnimation") == null) { rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight)); { if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteAnimation Component"), true)) { m_Sel.gameObject.AddComponent("NcSpriteAnimation"); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); } // -------------------------------------------------------------- if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture && m_Sel.gameObject.GetComponent("NcSpriteTexture") == null) { rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight)); { if (FXMakerLayout.GUIButton(rect, GetHelpContent("Add NcSpriteTexture Component"), true)) { m_Sel.gameObject.AddComponent("NcSpriteTexture"); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); // -------------------------------------------------------------- int nSelIndex = EditorGUILayout.IntSlider(GetHelpContent("m_nCurrentIndex"), m_Sel.m_nCurrentIndex, 0, (spriteList == null ? 0 : spriteList.Count)); if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteTexture) { m_Sel.m_fUvScale = EditorGUILayout.FloatField(GetHelpContent("m_fUvScale"), m_Sel.m_fUvScale); } m_Sel.m_nMaxAtlasTextureSize = EditorGUILayout.IntPopup("nMaxAtlasTextureSize", m_Sel.m_nMaxAtlasTextureSize, NgEnum.m_TextureSizeStrings, NgEnum.m_TextureSizeIntters); // m_Sel.m_AtlasMaterial = (Material)EditorGUILayout.ObjectField(GetHelpContent("m_AtlasMaterial") , m_Sel.m_AtlasMaterial, typeof(Material), false); if (m_Sel.m_nCurrentIndex != nSelIndex) { m_Sel.m_nCurrentIndex = nSelIndex; m_Sel.SetSprite(nSelIndex, false); } // check // Add Button ------------------------------------------------------ EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nAddHeight * 2)); { Rect lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 0, 1); if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Add Sprite"))) { bClickButton = true; m_Sel.AddSpriteNode(); } if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("Build Sprite"))) { bClickButton = true; BuildSpriteAtlas(m_Sel.renderer.sharedMaterial); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 2, 1), GetHelpContent("Clear All"), (0 < m_Sel.GetSpriteNodeCount()))) { bClickButton = true; if (m_FxmPopupManager != null) { m_FxmPopupManager.CloseNcPrefabPopup(); } m_Sel.ClearAllSpriteNode(); } lineRect = FXMakerLayout.GetInnerVerticalRect(rect, 2, 1, 1); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 0, 1), GetHelpContent("Sequence"), (0 < m_Sel.GetSpriteNodeCount()))) { m_Sel.m_bSequenceMode = true; bClickButton = true; m_Sel.SetSprite(0, false); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(lineRect, 3, 1, 1), GetHelpContent("NewMaterial"), true)) { Material newMat = new Material(m_Sel.renderer.sharedMaterial); string matPath = AssetDatabase.GetAssetPath(m_Sel.renderer.sharedMaterial); NgMaterial.SaveMaterial(newMat, NgFile.TrimFilenameExt(matPath), m_Sel.name); m_Sel.renderer.sharedMaterial = newMat; // m_Sel.renderer.sharedMaterial = (Material)AssetDatabase.LoadAssetAtPath(savePath, typeof(Material)); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); // Select ShotType ------------------------------------------------- // showType = (NcSpriteFactory.SHOW_TYPE)EditorGUILayout.EnumPopup (GetHelpContent("m_ShowType") , showType); // -------------------------------------------------------------- EditorGUILayout.Space(); NcSpriteFactory.SHOW_TYPE showType = (NcSpriteFactory.SHOW_TYPE)EditorPrefs.GetInt("NcSpriteFactory.SHOW_TYPE", 0); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 0, 1), showType == NcSpriteFactory.SHOW_TYPE.NONE, GetHelpContent("NONE"), true) ? NcSpriteFactory.SHOW_TYPE.NONE : showType; showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 1, 1), showType == NcSpriteFactory.SHOW_TYPE.ALL, GetHelpContent("ALL"), true) ? NcSpriteFactory.SHOW_TYPE.ALL : showType; if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 2, 1), showType == NcSpriteFactory.SHOW_TYPE.SPRITE, GetHelpContent("SPRITE"), true) ? NcSpriteFactory.SHOW_TYPE.SPRITE : showType; showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 3, 1), showType == NcSpriteFactory.SHOW_TYPE.ANIMATION, GetHelpContent("ANIMATION"), true) ? NcSpriteFactory.SHOW_TYPE.ANIMATION : showType; } showType = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 5, 4, 1), showType == NcSpriteFactory.SHOW_TYPE.EFFECT, GetHelpContent("EFFECT"), true) ? NcSpriteFactory.SHOW_TYPE.EFFECT : showType; GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); EditorPrefs.SetInt("NcSpriteFactory.SHOW_TYPE", ((int)showType)); // Show Option ------------------------------------------------- EditorGUILayout.Space(); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { m_Sel.m_bShowEffect = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 0, 1), m_Sel.m_bShowEffect, GetHelpContent("m_bShowEffect"), true); if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { m_Sel.m_bTestMode = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 1, 1), m_Sel.m_bTestMode, GetHelpContent("m_bTestMode"), true); m_Sel.m_bSequenceMode = FXMakerLayout.GUIToggle(FXMakerLayout.GetInnerHorizontalRect(rect, 3, 2, 1), m_Sel.m_bSequenceMode, GetHelpContent("m_bSequenceMode"), true); } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); // Node List ------------------------------------------------------ for (int n = 0; n < (spriteList != null ? spriteList.Count : 0); n++) { EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); // Load Texture --------------------------------------------------------- Texture2D selTexture = null; if (spriteList[n].m_TextureGUID != "") { selTexture = (Texture2D)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(spriteList[n].m_TextureGUID), typeof(Texture2D)); } // Enabled -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nLineHeight)); { Rect subRect; // enable spriteList[n].m_bIncludedAtlas = GUILayout.Toggle(spriteList[n].m_bIncludedAtlas, "Idx", GUILayout.Width(nLeftWidth)); // change index subRect = rect; subRect.x += nLeftWidth; subRect.width = nLineHeight * 2; int newPos = EditorGUI.IntPopup(subRect, n, NgConvert.GetIntStrings(0, spriteList.Count), NgConvert.GetIntegers(0, spriteList.Count)); if (newPos != n) { NcSpriteFactory.NcSpriteNode node = spriteList[n]; m_Sel.m_SpriteList.Remove(node); m_Sel.m_SpriteList.Insert(newPos, node); return; } // name subRect = rect; subRect.x += nLeftWidth + nLineHeight * 2; subRect.width -= nLeftWidth + nLineHeight * 2; spriteList[n].m_TextureName = selTexture == null ? "" : selTexture.name; GUI.Label(subRect, (selTexture == null ? "" : "(" + spriteList[n].m_nFrameCount + ") " + selTexture.name)); GUI.Box(subRect, ""); GUI.Box(rect, ""); // delete if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Del"))) { bClickButton = true; if (m_FxmPopupManager != null) { m_FxmPopupManager.CloseNcPrefabPopup(); } m_Sel.DeleteSpriteNode(n); return; } } EditorGUILayout.EndHorizontal(); // MaxAlpha ------------------------------------------------------------- spriteList[n].m_fMaxTextureAlpha = EditorGUILayout.FloatField(GetHelpContent("m_fMaxTextureAlpha"), spriteList[n].m_fMaxTextureAlpha); // Texture -------------------------------------------------------------- rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(nSpriteHeight)); { GUILayout.Label("", GUILayout.Width(nLeftWidth)); Rect subRect = rect; subRect.width = nLeftWidth; FXMakerLayout.GetOffsetRect(rect, 0, 5, 0, -5); EditorGUI.BeginChangeCheck(); selTexture = (Texture2D)EditorGUI.ObjectField(subRect, GetHelpContent(""), selTexture, typeof(Texture2D), false); if (EditorGUI.EndChangeCheck()) { if (selTexture != null) { spriteList[n].m_TextureGUID = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(selTexture)); } } if (selTexture != null) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { spriteList[n].m_nFrameCount = selTexture.width / selTexture.height; spriteList[n].m_nFrameSize = selTexture.height; m_Sel.m_nFrameSize = spriteList[n].m_nFrameSize; } else { spriteList[n].m_nFrameCount = 1; spriteList[n].m_nFrameSize = 1; m_Sel.m_nFrameSize = 1; } } // draw texture subRect = FXMakerLayout.GetOffsetRect(rect, nLeftWidth + 4, 0, 0, -4); if (selTexture != null) { GUI.DrawTexture(FXMakerLayout.GetOffsetRect(subRect, 0, 0, -nDelWidth, 0), selTexture, ScaleMode.ScaleToFit, true, selTexture.width / selTexture.height); } // delete if (GUI.Button(new Rect(subRect.x + subRect.width - nDelWidth, subRect.y, nDelWidth, subRect.height), GetHelpContent("Rmv"))) { spriteList[n].m_TextureGUID = ""; spriteList[n].m_nFrameCount = 0; spriteList[n].m_nFrameSize = 0; } GUI.Box(rect, ""); } EditorGUILayout.EndHorizontal(); // Change selIndex Event e = Event.current; if (e.type == EventType.MouseDown) { if (rect.Contains(e.mousePosition)) { nClickIndex = n; nClickButton = e.button; } } // SpriteNode ---------------------------------------------------------- if (bClickButton == false) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.SPRITE) { spriteList[n].m_bLoop = EditorGUILayout.Toggle(GetHelpContent("m_bLoop"), spriteList[n].m_bLoop); spriteList[n].m_fTime = EditorGUILayout.Slider(GetHelpContent("m_fTime"), spriteList[n].m_nFrameCount / spriteList[n].m_fFps, 0, 5, null); spriteList[n].m_fFps = EditorGUILayout.Slider(GetHelpContent("m_fFps"), spriteList[n].m_nFrameCount / spriteList[n].m_fTime, 50, 1, null); } if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation && showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.ANIMATION) { spriteList[n].m_nNextSpriteIndex = EditorGUILayout.Popup("m_nNextSpriteIndex", spriteList[n].m_nNextSpriteIndex + 1, GetSpriteNodeNames()) - 1; spriteList[n].m_nTestMode = EditorGUILayout.Popup("m_nTestMode", spriteList[n].m_nTestMode, NgConvert.ContentsToStrings(FxmTestControls.GetHcEffectControls_Trans(FxmTestControls.AXIS.Z)), GUILayout.MaxWidth(Screen.width)); spriteList[n].m_fTestSpeed = EditorGUILayout.FloatField("m_fTestSpeed", spriteList[n].m_fTestSpeed); SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f); SetMinValue(ref spriteList[n].m_fTestSpeed, 0.01f); } if (showType == NcSpriteFactory.SHOW_TYPE.ALL || showType == NcSpriteFactory.SHOW_TYPE.EFFECT) { // char effect ------------------------------------------------------------- spriteList[n].m_EffectPrefab = (GameObject)EditorGUILayout.ObjectField(GetHelpContent("m_EffectPrefab"), spriteList[n].m_EffectPrefab, typeof(GameObject), false, null); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f)); { if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelEffect"), (m_FxmPopupManager != null))) { m_FxmPopupManager.ShowSelectPrefabPopup(m_Sel, n, 0, true); } if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearEffect"), (spriteList[n].m_EffectPrefab != null))) { bClickButton = true; spriteList[n].m_EffectPrefab = null; } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); if (spriteList[n].m_EffectPrefab != null) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { spriteList[n].m_nEffectFrame = EditorGUILayout.IntSlider(GetHelpContent("m_nEffectFrame"), spriteList[n].m_nEffectFrame, 0, spriteList[n].m_nFrameCount, null); spriteList[n].m_bEffectOnlyFirst = EditorGUILayout.Toggle(GetHelpContent("m_bEffectOnlyFirst"), spriteList[n].m_bEffectOnlyFirst); } spriteList[n].m_fEffectSpeed = EditorGUILayout.FloatField("m_fEffectSpeed", spriteList[n].m_fEffectSpeed); spriteList[n].m_fEffectScale = EditorGUILayout.FloatField("m_fEffectScale", spriteList[n].m_fEffectScale); spriteList[n].m_EffectPos = EditorGUILayout.Vector3Field("m_EffectPos", spriteList[n].m_EffectPos, null); spriteList[n].m_EffectRot = EditorGUILayout.Vector3Field("m_EffectRot", spriteList[n].m_EffectRot, null); SetMinValue(ref spriteList[n].m_fEffectScale, 0.001f); } EditorGUILayout.Space(); // char sound ------------------------------------------------------------- spriteList[n].m_AudioClip = (AudioClip)EditorGUILayout.ObjectField(GetHelpContent("m_AudioClip"), spriteList[n].m_AudioClip, typeof(AudioClip), false, null); rect = EditorGUILayout.BeginHorizontal(GUILayout.Height(m_fButtonHeight * 0.7f)); { // if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 0, 1), GetHelpContent("SelAudio"), (m_FxmPopupManager != null))) // m_FxmPopupManager.ShowSelectAudioClipPopup(m_Sel); if (FXMakerLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(rect, 2, 1, 1), GetHelpContent("ClearAudio"), (spriteList[n].m_AudioClip != null))) { bClickButton = true; spriteList[n].m_AudioClip = null; } GUILayout.Label(""); } EditorGUILayout.EndHorizontal(); if (spriteList[n].m_AudioClip != null) { if (m_Sel.m_SpriteType == NcSpriteFactory.SPRITE_TYPE.NcSpriteAnimation) { spriteList[n].m_nSoundFrame = EditorGUILayout.IntSlider(GetHelpContent("m_nSoundFrame"), spriteList[n].m_nSoundFrame, 0, spriteList[n].m_nFrameCount, null); spriteList[n].m_bSoundOnlyFirst = EditorGUILayout.Toggle(GetHelpContent("m_bSoundOnlyFirst"), spriteList[n].m_bSoundOnlyFirst); } spriteList[n].m_bSoundLoop = EditorGUILayout.Toggle(GetHelpContent("m_bSoundLoop"), spriteList[n].m_bSoundLoop); spriteList[n].m_fSoundVolume = EditorGUILayout.Slider(GetHelpContent("m_fSoundVolume"), spriteList[n].m_fSoundVolume, 0, 1.0f, null); spriteList[n].m_fSoundPitch = EditorGUILayout.Slider(GetHelpContent("m_fSoundPitch"), spriteList[n].m_fSoundPitch, -3, 3.0f, null); } } } if (EditorGUI.EndChangeCheck()) { nClickIndex = n; } selTexture = null; } // Select Node ---------------------------------------------------- if (0 <= nClickIndex) { m_Sel.SetSprite(nClickIndex, false); if (m_Sel.m_bTestMode && 0 <= spriteList[nClickIndex].m_nTestMode && GetFXMakerMain()) { GetFXMakerMain().GetFXMakerControls().SetTransIndex(spriteList[nClickIndex].m_nTestMode, (4 <= spriteList[nClickIndex].m_nTestMode ? 1.8f : 1.0f), spriteList[nClickIndex].m_fTestSpeed); } // Rotate if (nClickButton == 1) { m_Sel.transform.Rotate(0, 180, 0); } nClickIndex = -1; bClickButton = true; } m_UndoManager.CheckDirty(); } // -------------------------------------------------------------- if ((EditorGUI.EndChangeCheck() || bClickButton) && GetFXMakerMain()) { GetFXMakerMain().CreateCurrentInstanceEffect(true); } // --------------------------------------------------------------------- if (GUI.tooltip != "") { m_LastTooltip = GUI.tooltip; } HelpBox(m_LastTooltip); }