Exemple #1
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);
            }
        }