public void SetData(PetPainterScriptObjectData data) { painterTableData.Id = data.Id; painterTableData.ImageName = data.ImageName; painterTableData.paths = data.paths; _currentEditSinglePath = painterTableData.paths[0]; }
public void ChangeToEditPath(int id) { PetPainterPathAttr attr = GetSinglePath(id); if (attr != null) { _currentEditSinglePath = attr; } }
public void OnSceneGUI() { //编辑器面板编辑路径 Event e = Event.current; if (e.type == EventType.mouseDown && e.button == 0 && e.alt) { Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, Mathf.Infinity)) { e.Use(); Vector3 local_point = creator.transform.InverseTransformPoint(hit.point); creator.AddCurrentWayPoint(local_point); } } Handles.BeginGUI(); Handles.Label(creator.transform.position, string.Format("当前路径:{0}", creator._currentEditSinglePath.path_id), style); Handles.EndGUI(); //获取point列表 PetPainterPathAttr _currentEditSinglePath = creator._currentEditSinglePath; if (_currentEditSinglePath != null) { current_pathpoints = _currentEditSinglePath.pathPoints; if (creator == null || current_pathpoints.Count <= 0) { return; } //绘制hander for (int i = 0; i < current_pathpoints.Count; i++) { Vector3 worldPoint = creator.transform.TransformPoint(current_pathpoints[i]); worldPoint = Handles.PositionHandle(worldPoint, Quaternion.identity); //为每一个节点画positionHandle Vector3 localPoint = creator.transform.InverseTransformPoint(worldPoint); localPoint.z = creator.point_z_value; current_pathpoints[i] = localPoint; Handles.BeginGUI(); Handles.Label(worldPoint, i.ToString(), style); Handles.EndGUI(); } } }
public void AddNewPath(int id, bool is_path_close) { PetPainterPathAttr pet_single_path = new PetPainterPathAttr(); pet_single_path.path_id = id; pet_single_path.path_name = string.Format("路径{0}", id); pet_single_path.is_close = is_path_close; if (auto_change_to_newadd_path) { _currentEditSinglePath = pet_single_path; } AddCurrentWayPoint(new Vector3(-200f, 0, 0)); AddCurrentWayPoint(new Vector3(200f, 0, 0)); painterTableData.paths.Add(pet_single_path); }
public void RemovePath(int id) { if (painterTableData.paths.Count > 0) { foreach (var singlepath in painterTableData.paths) { if (singlepath.path_id == id) { if (singlepath.path_id == _currentEditSinglePath.path_id) { painterTableData.paths.Remove(singlepath); _currentEditSinglePath = GetSinglePathByIndex(0); } else { painterTableData.paths.Remove(singlepath); } return; } } } }
public void ClearAllPathData() { _currentEditSinglePath = null; painterTableData.paths.Clear(); }