SceneSeparateData GetData()
        {
            string dataPath  = string.Format("{0}/sceneseparate.asset", GetScenePath());
            string scenePath = GetScenePath();

            if (m_Target.data == null)
            {
                m_Target.data = AssetDatabase.LoadAssetAtPath <SceneSeparateData>(dataPath);
            }
            if (m_Target.data == null)
            {
                SceneSeparateData obj = ScriptableObject.CreateInstance <SceneSeparateData>();
                if (!Directory.Exists(scenePath))
                {
                    Directory.CreateDirectory(scenePath);
                }
                AssetDatabase.CreateAsset(obj, dataPath);
                m_Target.data = obj;
            }
            return(m_Target.data);
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            SceneSeparateData separateData = GetData();

            separateData.sceneName      = EditorSceneManager.GetActiveScene().name;
            separateData.treeType       = (TreeType)EditorGUILayout.EnumPopup("Tree Type树类型:", separateData.treeType);
            separateData.treeDepth      = EditorGUILayout.IntField("treeDepth树深度:", separateData.treeDepth);
            separateData.asyn           = EditorGUILayout.Toggle("asyn是否异步:", separateData.asyn);
            separateData.maxCreateCount = EditorGUILayout.IntField("maxCreateCount最大创建数量:", separateData.maxCreateCount);
            separateData.minCreateCount = EditorGUILayout.IntField("minCreateCount最小创建数量:", separateData.minCreateCount);
            separateData.maxRefreshTime = EditorGUILayout.IntField("maxRefreshTime更新区域时间间隔:", separateData.maxRefreshTime);
            separateData.maxDestroyTime = EditorGUILayout.IntField("maxDestroyTime检查销毁时间间隔:", separateData.maxDestroyTime);
            EditorGUILayout.Space();

            SerializedObject serializedObject = new UnityEditor.SerializedObject(target);

            SerializedProperty debug_DrawObj = serializedObject.FindProperty("debug_DrawObj");

            debug_DrawObj.boolValue = EditorGUILayout.Toggle("显示树节点物体网格:", debug_DrawObj.boolValue);
            SerializedProperty debug_DrawMinDepth = serializedObject.FindProperty("debug_DrawMinDepth");

            debug_DrawMinDepth.intValue = EditorGUILayout.IntField("树最小深度:", debug_DrawMinDepth.intValue);
            SerializedProperty debug_DrawMaxDepth = serializedObject.FindProperty("debug_DrawMaxDepth");

            debug_DrawMaxDepth.intValue = EditorGUILayout.IntField("树最大深度:", debug_DrawMaxDepth.intValue);

            serializedObject.ApplyModifiedProperties();

            if (GUILayout.Button("拾取节点下的物体"))
            {
                Undo.RecordObject(target, "PickChilds");
                PickChilds();
            }

            if (GUILayout.Button("预览四叉树"))
            {
                m_Target.EditorInit();
                m_Target.EditorAddDataObjects();
            }

            if (GUILayout.Button("恢复场景"))
            {
                m_Target.EditorReBuild();
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("保存"))
            {
                EditorUtility.SetDirty(GetData());
                Undo.RecordObject(target, "SaveData");
                SaveData();
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            if (GUILayout.Button("移除节点下保存的预制体(记得备份)"))
            {
                Undo.RecordObject(target, "RemoveSavcedChilds");
                RemoveSavcedChilds();
            }
        }