//初始化函数 void Init() { minSize = new Vector2(600, 0); RenderSettings.fog = false; _delegate = new SceneView.OnSceneFunc(OnSceneFunc); SceneView.onSceneGUIDelegate += _delegate; m_sBornListPath = ""; m_sObstaclePath = ""; m_sNavigationPath = ""; //加载选择图片 ChangeTexture(ref _windowInstance.m_ObstcalePng); //加载prefab string sPrefabPath = "Assets/Z_Temp/Obstacle/SceneEditorPerfab/"; //ObsPrefabs = AssetDatabase.LoadAssetAtPath( sPrefabPath + "Obstacle.prefab", typeof(GameObject)) as GameObject; ; RegionBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "RegionBorn.prefab", typeof(GameObject)) as GameObject;; PointBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "PointBorn.prefab", typeof(GameObject)) as GameObject;; ScenePointBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "ScenePointBorn.prefab", typeof(GameObject)) as GameObject;; PathPointBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "PathPointBorn.prefab", typeof(GameObject)) as GameObject; PatrolBorn = AssetDatabase.LoadAssetAtPath(sPrefabPath + "PatrolBorn.prefab", typeof(GameObject)) as GameObject; //生成各个父节点 AllParent = GameObject.Find("Parent"); if (AllParent == null) { GameObject parent = AssetDatabase.LoadAssetAtPath(sPrefabPath + "Parent.prefab", typeof(GameObject)) as GameObject; AllParent = Instantiate(parent) as GameObject; AllParent.transform.position = new Vector3(0, 0, 0); AllParent.name = AllParent.name.Replace("(Clone)", ""); } m_csPathGrid = AllParent.GetComponent <PathGridComponent>(); m_csPathGrid.m_debugShow = true; CheekParent(); m_csPathGrid.InitArray(false); GetFloorHeight(); _windowInstance.position = new Rect(400, 90, 150, 940); BornInfoWindow.OpenWindow(); EditerDataClass._Instance.Init(); //InteractionTool.AddObserver(EditerDataClass._Instance); //InteractionTool.AddObserver(BornInfoWindow._Instance); // InteractionTool.InitObserver(); //自动导入阻挡文件 InteractionTool.Importobstacle(true); }
//绘制地图信息 void DrawMapInfo() { m_bShowMapInfo = EditorGUILayout.Foldout(m_bShowMapInfo, "地图相关信息"); if (m_bShowMapInfo) { StartSpace(1); m_csPathGrid.m_debugShow = EditorGUILayout.Toggle("是否显示地图格子", m_csPathGrid.m_debugShow); m_bShowRay = EditorGUILayout.Toggle("是否显示地图射线", m_bShowRay); m_bCanClickOtherObj = EditorGUILayout.Toggle("是否锁定其他对象", m_bCanClickOtherObj); m_bObsctaleMode = EditorGUILayout.Toggle("删除阻挡模式", m_bObsctaleMode); m_csPathGrid.m_debugColor = EditorGUILayout.ColorField("地图格子颜色", m_csPathGrid.m_debugColor); m_csPathGrid.m_bIsShowObstacle = EditorGUILayout.Toggle("隐藏阻挡", m_csPathGrid.m_bIsShowObstacle); m_bIsLockObstacle = EditorGUILayout.Toggle("锁定阻挡", m_bIsLockObstacle); Vector2 mapvect2 = EditorGUILayout.Vector2Field("地图大小", new Vector2((int)m_csPathGrid.m_numberOfColumns, (int)m_csPathGrid.m_numberOfRows)); m_csPathGrid.m_numberOfColumns = (int)mapvect2.x; m_csPathGrid.m_numberOfRows = (int)mapvect2.y; m_iCreateRectSize = EditorGUILayout.IntSlider(m_iCreateRectSize, 1, 40);//格子数 m_iMonseRectSize = (float)m_iCreateRectSize * 0.2f / (float)2; m_fPreObstaclePos = EditorGUILayout.FloatField("地图整体高度", m_fPreObstaclePos); BoxCollider pathgridcollider = AllParent.GetComponent <BoxCollider>(); pathgridcollider.center = new Vector3(((float)m_csPathGrid.m_numberOfColumns) / (float)2, ((float)m_csPathGrid.m_numberOfRows) / (float)2, 0); pathgridcollider.size = new Vector3(((int)mapvect2.x), ((int)mapvect2.y), 0); if (GUILayout.Button("匹配地图大小")) { GetMapMaxAndMin(); } if (GUILayout.Button("修正零点坐标")) { m_csPathGrid.InitArray(true); } EndSpace(); } }