/// <summary>
    /// 预计算预制体配置,最后还要进行合并
    /// </summary>
    private static void PreGeneratePrefabConfig()
    {
        //先刷新一遍资源数据库,把所有的资源都丢进来
        SaveAndRefershAssets();


        DeleteFileHelper(AssetBundleManager.GetPrefabConfigPath());
        DeleteFileHelper(AssetBundleManager.GetDependenicesResConfigPath());

        AssetBundleManager.ClearPrefabConfig();

        AssetBundleImporter.BeginPrefabAssetImport();
        AssetBundleImporter.BeginGenerateUnionRes();
        string[] assetss = AssetDatabase.FindAssets("t:Object", new string[] { AssetBundleImporter.PrefabPatch.Remove(AssetBundleImporter.PrefabPatch.Length - 1, 1),
                                                                               AssetBundleImporter.ArtistCommonAssetsPatch.Remove(AssetBundleImporter.ArtistCommonAssetsPatch.Length - 1, 1) });

        foreach (string patch1 in assetss)
        {
            string patch = AssetDatabase.GUIDToAssetPath(patch1);
            AssetBundleImporter.ImportSinglePrefab(patch, false);
        }

        AssetBundleImporter.EndGenerateUnionRes();
        AssetBundleImporter.EndPrefabAssetImport();
        SaveAndRefershAssets();
    }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            bool bDirty = false;

            pa.m_TextureSize     = EditorGUILayout.IntField("贴图大小:", pa.m_TextureSize);
            pa.m_ClipPlaneOffset = EditorGUILayout.FloatField("物体到水面的距离:", pa.m_ClipPlaneOffset);
            pa.EdgeBlendStength  = EditorGUILayout.Slider("水面边缘柔和:", pa.EdgeBlendStength, 0, 10);

            if (!Application.isPlaying)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(BakeCullMask, new GUIContent("显示层:"));
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }

            EditorGUILayout.LabelField("反射数目:" + pa.allVisibleRenderList.Count);
            BoundsPos = EditorGUILayout.BeginScrollView(BoundsPos);

            for (int i = 0; i < pa.WaterRefAeraList.Count; i++)
            {
                BoxCollider bc = pa.WaterRefAeraList[i];
                if (!bc)
                {
                    pa.WaterRefAeraList.RemoveAt(i);
                    continue;
                }
                EditorGUILayout.BeginHorizontal("box");
                bc = EditorGUILayout.ObjectField(bc, typeof(BoxCollider), true) as BoxCollider;
                if (GUILayout.Button("删除"))
                {
                    GameObject.DestroyImmediate(bc.gameObject);
                    pa.WaterRefAeraList.RemoveAt(i);
                }
                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();

            if (GUILayout.Button("增加反射区域"))
            {
                GameObject go = new GameObject();
                go.name = "WaterRefArea--" + pa.WaterRefAeraList.Count;
                go.transform.localScale = Vector3.one * 5.0f;
                go.transform.SetParent(pa.transform);
                Vector3 dir = EditorCamera.GetRotation() * Vector3.forward;
                go.transform.localRotation = Quaternion.identity;
                go.transform.position      = EditorCamera.GetPosition() + dir * 10;
                go.layer = Water.WaterObjLayer;
                BoxCollider box = go.AddComponent <BoxCollider>();

                box.isTrigger = true;
                pa.WaterRefAeraList.Add(box);

                Selection.activeGameObject = go;
            }

            if (GUILayout.Button("Bake"))
            {
                AssetBundleImporter.BeginPrefabAssetImport();
                BakeRender(pa);
                AssetBundleImporter.EndPrefabAssetImport();
                bDirty = true;
            }

            if (GUILayout.Button("Clear"))
            {
                ClearBake(pa);
                bDirty = true;
            }

            if (GUILayout.Button("Init"))
            {
                Water.Init();
            }
            bDirty |= GUI.changed;
            if (bDirty)
            {
                EditorUtility.SetDirty(pa);
            }
        }