Hello everyone. I’m using iTweenPath and I wonder if it is possible to move all nodes at once. I’m using an empty parent object and the path is the child object. move the parent object but the path does not change. Someone to help?
It is old, But I needed the same thing and couldn’t find it any place,
Hope it helps someone
I edited the Editor file to be something like this,
please check ,
//by Bob Berkebile : Pixelplacement : http://www.pixelplacement.com
using UnityEngine;
using UnityEditor;
using System.Collections;
[CustomEditor(typeof(iTweenPath))]
public class iTweenPathEditor : Editor
{
iTweenPath _target;
GUIStyle style = new GUIStyle();
public static int count = 0;
Vector3 OrigianlPosition;
bool GlobalMovment;
void OnEnable(){
//i like bold handle labels since I'm getting old:
style.fontStyle = FontStyle.Bold;
style.normal.textColor = Color.white;
_target = (iTweenPath)target;
//lock in a default path name:
if(!_target.initialized){
_target.initialized = true;
_target.pathName = "New Path " + ++count;
_target.initialName = _target.pathName;
OrigianlPosition = Vector3.zero;
}
}
public override void OnInspectorGUI(){
//path name:
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Path Name");
_target.pathName = EditorGUILayout.TextField(_target.pathName);
EditorGUILayout.EndHorizontal();
if(_target.pathName == ""){
_target.pathName = _target.initialName;
}
//path color:
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Path Color");
_target.pathColor = EditorGUILayout.ColorField(_target.pathColor);
EditorGUILayout.EndHorizontal();
//exploration segment count control:
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Node Count");
_target.nodeCount = Mathf.Clamp(EditorGUILayout.IntSlider(_target.nodeCount, 0, 15), 2,100);
EditorGUILayout.EndHorizontal();
//add node?
if(_target.nodeCount > _target.nodes.Count){
for (int i = 0; i < _target.nodeCount - _target.nodes.Count; i++) {
_target.nodes.Add(Vector3.zero);
}
}
//remove node?
if(_target.nodeCount < _target.nodes.Count){
if(EditorUtility.DisplayDialog("Remove path node?","Shortening the node list will permantently destory parts of your path. This operation cannot be undone.", "OK", "Cancel")){
int removeCount = _target.nodes.Count - _target.nodeCount;
_target.nodes.RemoveRange(_target.nodes.Count-removeCount,removeCount);
}else{
_target.nodeCount = _target.nodes.Count;
}
}
//node display:
EditorGUI.indentLevel = 4;
for (int i = 0; i < _target.nodes.Count; i++) {
_target.nodes <em>= EditorGUILayout.Vector3Field("Node " + (i+1), _target.nodes*);*</em>
* }*
* GlobalMovment = EditorGUILayout.Toggle (“GlobalMovment”, GlobalMovment);*
* if(!GlobalMovment){*
* OrigianlPosition = Vector3.zero;*
* }*
* //update and redraw:*
* if(GUI.changed){*
* EditorUtility.SetDirty(target);
_ }*
* }*
* void OnSceneGUI(){*
* if(target.enabled) { // dkoontz*
* if(target.nodes.Count > 0){
_ //allow path adjustment undo:*
* Undo.SetSnapshotTarget(target,“Adjust iTween Path”);
_ if (GlobalMovment) {*
* Vector3 newPo = Handles.PositionHandle (OrigianlPosition, Quaternion.identity);*
* for (int i = 0; i < target.nodes.Count; i++) {
_target.nodes = target.nodes - OrigianlPosition + newPo;
}*
* OrigianlPosition = newPo;
} else {
//path begin and end labels:_
Handles.Label(target.nodes[0], “'” + target.pathName + “’ Begin”, style);
Handles.Label(target.nodes[target.nodes.Count-1], “'” + target.pathName + “’ End”, style);*
* //node handle display:*
* for (int i = 0; i < target.nodes.Count; i++) {
_target.nodes = Handles.FreeMoveHandle (target.nodes , Quaternion.identity, 0.25f, Vector3.zero, Handles.RectangleCap);
} *
* }*
* }
} // dkoontz*
* }
}*
Now you will have a CheckBox that you can use to move all the points at Once,
a minor catch ( that you can easily change ) is that the Global Movement Handle is drawn at Vector3.zero_