private void DrawCircleTrigger(TriggerEditorData data) { EditorGUILayout.BeginHorizontal(); { Vector3 scale = data.m_SourceObj.transform.localScale; float realRange = scale.x; GUILayout.TextArea("触发器大小", GUILayout.Width(120f)); realRange = EditorGUILayout.Slider(realRange, 0f, 5f); scale = new Vector3(realRange, realRange, realRange); data.m_SourceObj.transform.localScale = scale; data.TriggerData.Scale.SetVector3(scale); } EditorGUILayout.EndHorizontal(); }
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); } }
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); } }
private void DrawCircleTrigger(TriggerEditorData data) { EditorGUILayout.BeginHorizontal(); { Vector3 scale = data.m_SourceObj.transform.localScale; float realRange = scale.x; GUILayout.TextArea("触发器大小", GUILayout.Width(120f)); realRange = EditorGUILayout.Slider(realRange, 0f, 5f); scale = new Vector3(realRange, realRange, realRange); data.m_SourceObj.transform.localScale = scale; data.TriggerData.Scale.SetVector3(scale); } EditorGUILayout.EndHorizontal(); }
private void DrawCubeTrigger(TriggerEditorData data) { }
private void DrawCubeTrigger(TriggerEditorData data) { }
void DrawTrigger() { if (NGUIEditorTools.DrawHeader("触发器配置")) { EditorGUILayout.BeginHorizontal(); { m_ETriggerAreaType = (ETriggerAreaType)EditorGUILayout.Popup((int)m_ETriggerAreaType, m_TriggerTypeList, GUILayout.Width(100f)); if (GUILayout.Button("添加一个触发器", GUILayout.Width(120f))) { AddTrigger(m_ETriggerAreaType, Vector3.zero, Vector3.zero, Vector3.one); } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < m_TriggerList.Count; ++i) { TriggerEditorData data = m_TriggerList[i]; GUIStyle textColor = new GUIStyle(); textColor.normal.textColor = data.m_bIsSelected ? Color.red:Color.white; if (NGUIEditorTools.DrawHeader(m_TriggerList[i].TriggerData.AreaType.ToString())) { EditorGUILayout.BeginHorizontal(); { if (GUILayout.Button("调整触发器位置", textColor, GUILayout.Width(120f))) { m_nCurrentSettingPosTriggerIndex = i; TerrainEditorRuntime.Instance.SetRaycastCallBack(SetTriggerPos); } if (GUILayout.Button("删除触发器", textColor, GUILayout.Width(120f))) { m_RemovingTriggerList.Add(m_TriggerList[i]); } if (GUILayout.Button("编辑触发器事件", textColor, GUILayout.Width(120f))) { TerrainTriggerNodeEditorWindow.Instance.OpenWindow(data.TriggerData); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Vector3 tmpPos = data.m_SourceObj.transform.position; GUILayout.TextArea("触发器位置", textColor, GUILayout.Width(120f)); GUILayout.Label(tmpPos.ToString(), GUILayout.Width(100f)); GUILayout.Label("x", GUILayout.Width(20f)); tmpPos.x = EditorGUILayout.FloatField(tmpPos.x); GUILayout.Label("y", GUILayout.Width(20f)); tmpPos.y = EditorGUILayout.FloatField(tmpPos.y); GUILayout.Label("z", GUILayout.Width(20f)); tmpPos.z = EditorGUILayout.FloatField(tmpPos.z); data.m_SourceObj.transform.position = tmpPos; data.TriggerData.Pos.SetVector3(data.m_SourceObj.transform.position); } EditorGUILayout.EndHorizontal(); switch (data.TriggerData.AreaType) { case ETriggerAreaType.Cube: DrawCubeTrigger(data); break; case ETriggerAreaType.Sphere: DrawCircleTrigger(data); break; default: break; } } } CheckRemovingTrigger(); } }