コード例 #1
0
    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();
        }
    }
コード例 #2
0
    void SaveAddCurvePrefab(bool bOverwrite)
    {
        if (m_nProjectIndex < 0)
        {
            return;
        }

        GameObject       saveObj = (GameObject)PrefabUtility.InstantiatePrefab(m_CurveAniObjects[m_nProjectIndex]);
        NcCurveAnimation saveCom;
        int nSaveIndex;

        // add component
        if (m_bOnlyCurve)
        {
            saveCom = saveObj.GetComponent <NcCurveAnimation>();
            if (saveCom == null)
            {
                saveCom = saveObj.AddComponent <NcCurveAnimation>();
            }
        }
        else
        {
            NcCurveAnimation[] curveAnis = saveObj.GetComponents <NcCurveAnimation>();
            if (curveAnis.Length < NcCurveAnimation.NcInfoCurve.m_TypeName.Length)
            {
                for (int n = curveAnis.Length; n < NcCurveAnimation.NcInfoCurve.m_TypeName.Length; n++)
                {
                    saveObj.AddComponent <NcCurveAnimation>();
                }
                curveAnis = saveObj.GetComponents <NcCurveAnimation>();
            }
            saveCom = curveAnis[(int)m_OriCurveInfo.m_ApplyType];
        }

        if (bOverwrite)
        {
            // update curve
            nSaveIndex = m_CurveInfos[m_nObjectIndex].m_nTag;
            saveCom.SetCurveInfo(nSaveIndex, m_OriCurveInfo);
            nSaveIndex = m_nObjectIndex;
        }
        else
        {
            // add curve
            nSaveIndex = saveCom.AddCurveInfo(m_OriCurveInfo);
        }
        saveCom.SortCurveInfo();

        // change Enabled
        saveCom.GetCurveInfo(nSaveIndex).m_bEnabled = true;

        PrefabUtility.ReplacePrefab(saveObj, m_CurveAniObjects[m_nProjectIndex]);
        FXMakerAsset.AssetDatabaseSaveAssets();
        DestroyImmediate(saveObj);
    }
コード例 #3
0
    void DeleteCurveInfo(int nIndex)
    {
        GameObject saveObj = (GameObject)PrefabUtility.InstantiatePrefab(m_CurveAniObjects[m_nProjectIndex]);

        if (m_bOnlyCurve)
        {
            NcCurveAnimation saveCom = saveObj.GetComponent <NcCurveAnimation>();
            if (saveCom != null)
            {
                saveCom.DeleteCurveInfo(m_CurveInfos[nIndex].m_nTag);
            }
        }
        else
        {
            NcCurveAnimation[]           curveAnis    = saveObj.GetComponents <NcCurveAnimation>();
            NcCurveAnimation.NcInfoCurve delCurveInfo = m_CurveInfos[nIndex];

            foreach (NcCurveAnimation curveAni in curveAnis)
            {
                List <NcCurveAnimation.NcInfoCurve> curveInfoList = curveAni.m_CurveInfoList;
                for (int n = 0; n < curveInfoList.Count; n++)
                {
                    NcCurveAnimation.NcInfoCurve curveInfo = curveInfoList[n];
                    if (curveInfo.m_ApplyType == delCurveInfo.m_ApplyType && curveInfo.m_nTag == delCurveInfo.m_nTag)
                    {
                        curveInfoList.Remove(curveInfo);
                        break;
                    }
                }
            }
        }

        PrefabUtility.ReplacePrefab(saveObj, m_CurveAniObjects[m_nProjectIndex]);
        FXMakerAsset.AssetDatabaseSaveAssets();
        DestroyImmediate(saveObj);

        // update scrolllist
        int nObjectIndex = m_nObjectIndex;

        if (nIndex < m_nObjectIndex)
        {
            nObjectIndex = m_nObjectIndex - 1;
        }
        if (nIndex == m_nObjectIndex)
        {
            nObjectIndex = -1;
        }
        LoadObjects();
        m_nObjectIndex = nObjectIndex;
    }
コード例 #4
0
	void SaveCurrentObjectToPrefabFile()
	{
		if (m_nProjectIndex < 0)
			return;

		if (FXMakerEffect.inst.m_DefaultEmptyPrefab == null)
		{
			Debug.LogError("FXMakerMain.m_DefaultEmptyPrefab is null");
			return;
		}

		string dstPath = NgFile.CombinePath(m_LoadDirectory, m_SaveFilename + ".prefab");

		dstPath = NgAsset.CreateDefaultUniquePrefab(FXMakerEffect.inst.m_DefaultEmptyPrefab, dstPath);

		GameObject			newPrefab	= NgAsset.LoadPrefab(dstPath);
		PrefabUtility.ReplacePrefab(m_SelectedTransform.gameObject, newPrefab);
		FXMakerAsset.AssetDatabaseSaveAssets();
	}
コード例 #5
0
    void SaveCurveAniToPrefabFile()
    {
        if (m_nProjectIndex < 0)
        {
            return;
        }

        if (m_DefaultSavePrefab == null)
        {
            Debug.LogError("FxmFolderPopup_NcCurveAnimation.m_DefaultSavePrefab is null");
            return;
        }

        string dstPath = NgFile.CombinePath(m_LoadDirectory, m_NcCurveAni_FileKeyword + m_SaveFilename + ".prefab");

        dstPath = NgAsset.CreateDefaultUniquePrefab(m_DefaultSavePrefab, dstPath);

        GameObject       newPrefab = NgAsset.LoadPrefab(dstPath);
        NcCurveAnimation newCom    = newPrefab.AddComponent <NcCurveAnimation>();

        m_CurrentCurveAnimation.CopyTo(newCom, false);
        FXMakerAsset.AssetDatabaseSaveAssets();
    }
コード例 #6
0
    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();
    }