For starters, I want to state clearly that I’m not the original author of this mod for HOTween. Credits go to the user by the name of Vesuvio.
I updated it with a new feature, which is the reason I created this thread (we, me and HOTween’s author, couldn’t reach Vesuvio for him to update his linked version).
Here is the content of it’s original post, in HOTween’s thread, with the download link of the original version in case you still want this one:
And now, about the upgrade (I also merely copy/paste my own post in HOTween’s thread, because I’m lazy…):
I found that it was missing a cool feature, which I was in need for, which I actually implemented: I found great the interface with the Vector3 Array as control points, but I really needed to be able to control them via actual transforms within the scene, so that I (in fact, my LD ) don’t need to match by hand the Vector3 points with our acual checkpoints/colliders/etc. from the scene. Small example as screenshot (one can see the editor on the right, and the cube I used as node 3 and 6)
Here a brief of the features:
Still works fine like it used to, so if you don’t wanna change it’s fine.
Instead of having to choose the complete system you want to use (Vector3 or Transforms), you can mix them!
So for each entry in the list, you can link an optional Target (Transform); if so, the Target will override the usual behavior of this Point, meaning that the Point will have for values the Transform.position values.
The handles still work, even with a Target set! So once the target is setup, you can move both of them (the Target PLUS the associated Point) either by moving the Target within the scene, by using the HOPath handles or even using the usual Vector3 text inputs
You can of course link several Points to the same Target, they will all be updated when the Target is moved.
All the other features of HOPath are linked to it => you can still Add, Remove, Swap, Undo and even edit multiple paths at once.
I also edited quickly the demoScene in order to showcase a use of this feature on one of the 2 paths.
You can download the upgraded version at the bottom of this post.
P.S. Just want to state that a couple of parts of the editor were breaking when I first imported the original HOPath package (i.e. RegisterPaths() and the EditorGUILayout.Vector3Field(…)), so I fixed them. I don’t know if that’s because of my version of Unity or anyhing else, but if that breaks it for you I apologize and let you fix it by yourself! (Nothing complicated, I had only to edit a couple of lines, which should be pointed at anyways by Unity if broken)
Maybe you should put this up on Github so we can make future changes to HOPath? Doesn’t seem to be maintained. I can think of a few additions to it I could push up.
Hey.
I unfortunately currently don’t have any Github account, and I don’t see the point of making one only for this.
And as I’m not the original author, I didn’t intend to overstep on his package, eventhough I admit I have no idea if it’s still being maintained or not at this point (probably not though, as I didn’t get any answer at the time I made this addition IIRC).
Again, I’m not the original author, I simply added a couple of features I needed to make it easier to use for my project, and felt like someone could need them aswell so shared
If you really want to, feel free to upload it on a Github account of yours (speaking only on my behalf though), everything I have should already be included in that package anyways! I don’t feel like I added that much that I should care about any form of authoring rights or credits or whatever anyways, so do as you please!
Hi, Le nain. When I build to “x86” player,Some errors.How can I fix it.Thanks.
Assets/Holoville/HOPath/PathPreview.cs(2,7): error CS0246: The type or namespace name `UnityEditor’ could not be found. Are you missing a using directive or an assembly reference?
Hey Jason18.
Hmmm, I didn’t actually build any game before I packaged it, which explains that I forgot this, sorry for that (though I’m not the only one, else it would work because the error lies in the code I didn’t write ^^).
Basically, it’s telling you that it can’t find the namespace UnityEditor, which is pretty normal because it’s only Editor stuff and thus not included in builds. In order to fix this, you need to tell the compiler not to include any call to this namespace when building by wrapping the editor code with preprocessor commands:
#if UNITY_EDITOR
using UnityEditor;
#endif
Now, this problem may appear somewhere else in the file once you fix this one, I can’t tell you for sure now as I don’t have my workspace at home. Try for yourself by fixing this one already, and if others come up do the same thing. If you still have trouble because of other errors on Monday, leave another message and I’ll probbaly be able to help.
Hey Le nain.
How can I fix this error:
Assets/Holoville/HOPath/PathPreview.cs(2,7): error CS0246: The type or namespace name UnityEditor' could not be found. Are you missing a using directive or an assembly reference? Even when added top code that yourself said, i recieve another error: Assets/Holoville/HOPath/PathPreview.cs(163,49): error CS0103: The name Handles’ does not exist in the current context
please help me my friend.
Hey again
PathPreview.cs use UnityEditor but this script has not put in the Editor folder.and when i put it into Editor folder, i recieve a lot of errors.i said meybe this help you until you can help me!!!
I tested with Unity 5 and got the same errors. Sorry for that. It’s basically the same thing (yet still not my code, the errors come from the original package), some stuff that isn’t available when building isn’t tagged correctly.
It was a nice attempt putting it in the Editor folder but won’t work, due to how the original author coded it.
[HOW TO FIX]
Like I said (but with more things), simply encapsulate the following things with #if UNITY_EDITOR … #endif
in PathPreview.cs
using UnityEditor;
The entire public void DrawPreview() method around line 125.
The entire private void DrawPreview(float t, bool p_drawTrig) method around line 139.
in HOPath.cs
The entire public void DrawPath() method around line 32.
Hi, just wondering what “optional target” is. Is this used say where I want my object to have an alternate path? If so, how can I control which path it takes (e.g. more likely to go down one path than the other).
Thanks
No, it’s just the part I actually added to the original package:
In the original plugin, the only way for you to setup a control point is to specify a position using the x y z prompts.
→ In my (this one) upgraded version, I added the possibility to use a Transform instead of the x y z prompts, which is what the Optional Target is. If you drag’n’drop a GameObject in this field, its own position will be used as a control point. This way, you can directly move the transform and the path will be updated accordingly.
For instance, it’s much easier to edit your path afterwards by manually moving the transform in the editor.
I’ve only used it in one project, and it was a 3D one. Never tried using in 2D.
I’m not the one who made the original plugin, so I don’t know all the logic behind it. I only added this Optional Target.
I don’t really have time to dive in it for you, sorry.
You can try to contact the original creator, Vesuvio, for help, but I’m not really sure he’s around anymore. This package is quite old now, and has never been maintained, so it’s not totally a surprised if it’s not all working correctly after all these Unity updates.