private void AddTrigger(ETriggerAreaType TriggerAreaType, Vector3 position, Vector3 rotation, Vector3 scale, int targetId = 0, int enterLimitId = 0, int exitLimitId = 0, int enterFuncId = 0, int exitFuncId = 0) { GameObject sourceObj = m_TriggerTemplateMap[TriggerAreaType]; if (null == sourceObj) { Debug.Log(TriggerAreaType.ToString() + " " + m_TriggerTemplateMap.Count); } else { GameObject instance = GameObject.Instantiate(sourceObj); ComponentTool.Attach(m_ObjTriggerRoot.transform, instance.transform); TriggerEditorData elem = new TriggerEditorData(); elem.TriggerData = new TerrainTriggerData(); elem.TriggerData.Pos = new ThriftVector3(); elem.TriggerData.Rot = new ThriftVector3(); elem.TriggerData.Scale = new ThriftVector3(); elem.TriggerData.Pos.SetVector3(position); elem.TriggerData.Rot.SetVector3(rotation); elem.TriggerData.Scale.SetVector3(scale); elem.TriggerData.AreaType = TriggerAreaType; elem.TriggerData.TargetMethodId = targetId; elem.TriggerData.EnterLimitMethodId = enterLimitId; elem.TriggerData.ExitLimitMethodId = exitLimitId; elem.TriggerData.EnterFuncMethodId = enterFuncId; elem.TriggerData.ExitFuncMethodId = exitFuncId; elem.m_SourceObj = instance; elem.m_SourceObj.transform.position = position; elem.m_SourceObj.transform.eulerAngles = rotation; elem.m_SourceObj.transform.localScale = scale; m_TriggerList.Add(elem); } }
void Init() { //m_strDataPath = Application.persistentDataPath + "/EditorData/terrainConfig_txtpkg.bytes"; m_strDataPath = Application.dataPath + "/EditorCommon/EditorResources/mmAdv/1.0/terrainConfig_txtpkg.bytes"; GameObject RootObj = GameObject.Find("TerrainEditorRoot"); m_ObjSceneRoot = GameObject.Find("SceneRoot"); m_ObjTriggerRoot = GameObject.Find("TriggerRoot"); var TriggerTemplateRoot = GameObject.Find("TriggerTemplateRoot"); m_ObjNpcRoot = GameObject.Find("NpcRoot"); if (null == RootObj || null == m_ObjSceneRoot || null == m_ObjTriggerRoot || null == TriggerTemplateRoot) { Debug.LogError("wrong scene"); } // init trigger int triggrCount = TriggerTemplateRoot.transform.childCount; m_TriggerTemplateMap = new Dictionary <ETriggerAreaType, GameObject>(triggrCount); m_TriggerTypeList = new string[triggrCount]; for (int i = 0; i < triggrCount; ++i) { ETriggerAreaType type = (ETriggerAreaType)(i); GameObject elem = TriggerTemplateRoot.transform.GetChild(i).gameObject; m_TriggerTemplateMap.Add(type, elem); m_TriggerTypeList[i] = type.ToString(); } NpcConfigTable npcConfigTable = ConfigManager.Instance.GetNpcTable(); if (null == npcConfigTable) { EditorUtility.DisplayDialog("", "npc配置文件读取失败", "ok"); ClearData(); CloseWindow(); return; } m_NpcTypeList = new string[npcConfigTable.NpcCofigMap.Count]; int tmpIndex = 0; foreach (var elem in npcConfigTable.NpcCofigMap) { m_NpcTypeList[tmpIndex++] = elem.Key.ToString(); } m_RemovingNpcList = new System.Collections.Generic.List <NpcEditorData>(); m_NpcList = new System.Collections.Generic.List <NpcEditorData>(); m_TriggerList = new System.Collections.Generic.List <TriggerEditorData>(); m_ETriggerAreaType = ETriggerAreaType.Sphere; m_RemovingTriggerList = new System.Collections.Generic.List <TriggerEditorData>(); m_MapNameInputBuffer = string.Empty; m_iSelectedNpcId = 0; CharactorConfigTable playerConfigTable = ConfigManager.Instance.GetCharactorConfigTable(); if (null == playerConfigTable) { EditorUtility.DisplayDialog("", "playerConfigTable 配置文件读取失败", "ok"); return; } m_PlayerTypeList = new string[playerConfigTable.CharactorCofigMap.Count]; tmpIndex = 0; foreach (var elem in playerConfigTable.CharactorCofigMap) { m_PlayerTypeList[tmpIndex++] = elem.Key.ToString(); } TerrainEditorRuntime.Instance.SetSelectCallBack(OnClickCallBack); Debug.Log(" initialize terrain"); }