示例#1
0
 static void ClearMat()
 {
     CommonAssets.enumMat.cb = (mat, path) =>
     {
         ClearMat(mat);
     };
     CommonAssets.EnumAsset <Material>(CommonAssets.enumMat, "ClearMat");
 }
示例#2
0
        static void CreateFaceData()
        {
            string path = "Assets/BundleRes/Config/FaceData.asset";

            if (!File.Exists(path))
            {
                FaceData fd = ScriptableObject.CreateInstance <FaceData>();
                CommonAssets.CreateAsset <FaceData>("Assets/BundleRes/Config", "FaceData", ".asset", fd);
            }
        }
示例#3
0
 public static void CreateDummyMat(string name, Shader shader, BlendMode blendMode, KeywordFlags keyWord, bool enableLightMap, bool enableShadow)
 {
     if (shader != null)
     {
         Material mat = new Material(shader);
         RefeshMat(mat, blendMode, keyWord, enableLightMap, enableShadow);
         CommonAssets.CreateAsset <Material>(string.Format("{0}/{1}",
                                                           AssetsConfig.GlobalAssetsConfig.ResourcePath,
                                                           AssetsConfig.GlobalAssetsConfig.DummyMatFolder), name, ".mat", mat);
     }
 }
示例#4
0
        internal static void ExtractMaterialsFromAsset(ModelImporter modelImporter, string destinationPath)
        {
            SerializedObject   serializedObject = new UnityEditor.SerializedObject(modelImporter);
            SerializedProperty materials        = serializedObject.FindProperty("m_Materials");

            for (int i = 0; i < materials.arraySize; ++i)
            {
                SerializedProperty arrayElementAtIndex = materials.GetArrayElementAtIndex(i);
                string             stringValue         = arrayElementAtIndex.FindPropertyRelative("name").stringValue;
                Material           mat = null;
                for (int j = 0; j < AssetsConfig.GlobalAssetsConfig.MaterialShaderMap.Length; j += 2)
                {
                    string keys  = AssetsConfig.GlobalAssetsConfig.MaterialShaderMap[j];
                    string value = AssetsConfig.GlobalAssetsConfig.MaterialShaderMap[j + 1];
                    if (string.IsNullOrEmpty(keys))
                    {
                        mat = new Material(Shader.Find(value));
                    }
                    else
                    {
                        string[] keysList = keys.Split('|');
                        foreach (string key in keysList)
                        {
                            if (stringValue.EndsWith(key))
                            {
                                mat = new Material(Shader.Find(value));
                                break;
                            }
                        }
                    }
                }
                if (mat != null)
                {
                    mat.name = stringValue;
                    Material newMat = AssetDatabase.LoadAssetAtPath <Material>(string.Format("{0}/{1}.mat", destinationPath, stringValue));
                    if (newMat != null)
                    {
                        newMat.shader = mat.shader;
                    }
                    else
                    {
                        newMat = CommonAssets.CreateAsset <Material>(destinationPath, stringValue, ".mat", mat);
                    }
                    ClearMat(newMat);
                    if (newMat != mat)
                    {
                        Object.DestroyImmediate(mat);
                    }
                }
            }
        }
示例#5
0
        public override void OnInspectorGUI()
        {
            if (faceData != null)
            {
                GUILayout.Label("Face Config Data", EditorStyles.boldLabel);
                GUIFacePart <HeadData>("脸型", 0, ref faceData.headData);
                GUIFacePart <SenseData>("五官", 1, ref faceData.senseData);
                GUIFacePart <PaintData>("妆容", 2, ref faceData.paintData);

                GUILayout.Space(5);
                if (GUILayout.Button("Save", GUILayout.MaxWidth(100)))
                {
                    faceData.OnSave();
                    CommonAssets.SaveAsset(faceData);
                }
            }
            serializedObject.ApplyModifiedProperties();
        }