iTweenPath.cs
[pyg language="csharp" s="monokai" ]
//Slight additions for a cleaner interface by Jacob Pennock
//source by Bob Berkebile : Pixelplacement : http://www.pixelplacement.com using UnityEngine;
using System.Collections.Generic; public enum iTweenPathCap {Default, Sphere, Cube, Dot, Circle,Square} public class iTweenPath : MonoBehaviour
{
public string pathName =””;
public Color pathColor = Color.cyan;
public iTweenPathCap capType;
public float capSize;
public List nodes = new List(){Vector3.zero, Vector3.zero};
public int nodeCount;
public static Dictionary paths = new Dictionary();
public bool initialized = false;
public string initialName = “”; void OnEnable(){
paths.Add(pathName.ToLower(), this);
} void OnDrawGizmosSelected(){
if(enabled) { // dkoontz
if(nodes.Count > ){
iTween.DrawPath(nodes.ToArray(), pathColor);
}
} // dkoontz
} public static Vector3[] GetPath(string requestedName){
requestedName = requestedName.ToLower();
if(paths.ContainsKey(requestedName)){
return paths[requestedName].nodes.ToArray();
}else{
Debug.Log(“No path with that name exists! Are you sure you wrote it correctly?”);
return null;
}
}
}
[/pyg] iTweenPathEditor.cs
[pyg language="csharp" s="monokai" ]
//Slight additions for a cleaner interface by Jacob Pennock
//source 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 = ; 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;
}
} 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(); //Node Type
_target.capType = (iTweenPathCap)EditorGUILayout.EnumPopup(“Node Type”,_target.capType); //Node size
if(_target.capType != iTweenPathCap.Default)
{
_target.capSize = EditorGUILayout.Slider(“Node Size”,_target.capSize, 0.5f, 5.0f);
} //exploration segment count control:
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel(“Node Count”);
_target.nodeCount = Mathf.Clamp(EditorGUILayout.IntSlider(_target.nodeCount, , ), ,);
EditorGUILayout.EndHorizontal(); //add node?
if(_target.nodeCount > _target.nodes.Count){
for (int i = ; 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 = ;
for (int i = ; i < _target.nodes.Count; i++) {
_target.nodes[i] = EditorGUILayout.Vector3Field("Node " + (i+), _target.nodes[i]);
} //update and redraw:
if(GUI.changed){
EditorUtility.SetDirty(_target);
}
} void OnSceneGUI(){
if(_target.enabled) { // dkoontz
if(_target.nodes.Count > ){
//allow path adjustment undo:
Undo.SetSnapshotTarget(_target,”Adjust iTween Path”); //path begin and end labels:
Handles.Label(_target.nodes[], “‘” + _target.pathName + “‘ Begin”, style);
Handles.Label(_target.nodes[_target.nodes.Count-], “‘” + _target.pathName + “‘ End”, style); //node handle display:
DrawPathCaps();
}
} // dkoontz
} void DrawPathCaps()
{
switch(_target.capType)
{
case iTweenPathCap.Default:
for (int i = ; i < _target.nodes.Count; i++)
{
_target.nodes[i] = Handles.PositionHandle(_target.nodes[i], Quaternion.identity);
}
break;
case iTweenPathCap.Sphere:
Handles.color = _target.pathColor;
for (int i = ; i < _target.nodes.Count; i++)
{
_target.nodes[i] = Handles.FreeMoveHandle(_target.nodes[i],Quaternion.identity,_target.capSize,Vector3.zero,Handles.SphereCap);
}
break;
case iTweenPathCap.Cube:
Handles.color = _target.pathColor;
for (int i = ; i < _target.nodes.Count; i++)
{
_target.nodes[i] = Handles.FreeMoveHandle(_target.nodes[i],Quaternion.identity,_target.capSize,Vector3.zero,Handles.CubeCap);
}
break;
case iTweenPathCap.Dot:
Handles.color = _target.pathColor;
for (int i = ; i < _target.nodes.Count; i++)
{
_target.nodes[i] = Handles.FreeMoveHandle(_target.nodes[i],Quaternion.identity,_target.capSize,Vector3.zero,Handles.DotCap);
}
break;
case iTweenPathCap.Circle:
Handles.color = _target.pathColor;
for (int i = ; i < _target.nodes.Count; i++)
{
_target.nodes[i] = Handles.FreeMoveHandle(_target.nodes[i],Quaternion.identity,_target.capSize,Vector3.zero,Handles.CircleCap);
}
break;
case iTweenPathCap.Square:
Handles.color = _target.pathColor;
for (int i = ; i < _target.nodes.Count; i++)
{
_target.nodes[i] = Handles.FreeMoveHandle(_target.nodes[i],Quaternion.identity,_target.capSize,Vector3.zero,Handles.RectangleCap);
}
break;
}
}
}
[/pyg]

Cleaner ITweenPath Source的更多相关文章

  1. RFIDler - An open source Software Defined RFID Reader/Writer/Emulator

    https://www.kickstarter.com/projects/1708444109/rfidler-a-software-defined-rfid-reader-writer-emul h ...

  2. Using Open Source Static Libraries in Xcode 4

    Using Open Source Static Libraries in Xcode 4 Xcode 4.0.1 allows us to more easily create and use th ...

  3. Cleaner, more elegant, and harder to recognize (msdn blog)

    It appears that some people interpreted the title of one of my rants from many months ago, "Cle ...

  4. AutoMapper:Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type

    异常处理汇总-后端系列 http://www.cnblogs.com/dunitian/p/4523006.html 应用场景:ViewModel==>Mode映射的时候出错 AutoMappe ...

  5. mysql-5.6.34 Installation from Source code

    Took me a while to suffer from the first successful souce code installation of mysql-5.6.34. Just pu ...

  6. source /etc/profile报错-bash: id:command is not found

    由于误操作导致 source /etc/profile 报错 -bash: id:command is not found 此时,linux下很多命令到不能能用,包括vi ls 等... 可以使用 e ...

  7. eclipse调试(debug)的时候,出现Source not found,Edit Source Lookup Path,一闪而过

    问题描述 使用Eclipse调试代码的时候,打了断点,经常出现Source not found,网上找了半天,大部分提示点击Edit Source Lookup Path,添加被调试的工程,然而往往没 ...

  8. Oracle使用java source调用外部程序

    需求 Oracle调用第三方外部程序.Oracle使用sqluldr2快速导出大批量数据,然后用winrar压缩后发送邮件. 本文档主要实现前两步需求,发送邮件程序这里不再说明. 原码 授权 begi ...

  9. Perforce 与Source Insight, Visual Studio集成

    转自:http://shashanzhao.com/archives/837.html 1.Perforce 首先需要为perforce设置系统环境变量,以便perforce命令行可以正常使用. 环境 ...

随机推荐

  1. FFTW3学习笔记3:FFTW 和 CUFFT 的使用对比

    一.流程 1.使用cufftHandle创建句柄 2.使用cufftPlan1d(),cufftPlan3d(),cufftPlan3d(),cufftPlanMany()对句柄进行配置,主要是配置句 ...

  2. codevs 1102 采药 2005年NOIP全国联赛普及组

    1102 采药 2005年NOIP全国联赛普及组  时间限制: 1 s  空间限制: 128000 KB gold   题目描述 Description 辰辰是个天资聪颖的孩子,他的梦想是成为世界上最 ...

  3. bzoj 1010 斜率优化DP

    我的第二道斜率DP. 收获: 1.假设两个位置:p<q<i,然后让某一位置优,看其满足什么性质,所谓斜率优化就是满足: (g[q]-g[p])/(f[q]-f[p])  op h[i] 要 ...

  4. [转][Android]Android数据的四种存储方式

    android.database.sqlite类 SQLiteQueryBuilder java.lang.Object android.database.sqlite.SQLiteQueryBuil ...

  5. Codeforces Beta Round #7 D. Palindrome Degree hash

    D. Palindrome Degree 题目连接: http://www.codeforces.com/contest/7/problem/D Description String s of len ...

  6. 《C# to IL》第二章 IL基础

    如果你真的想要理解C#代码,那么最好的方法就是通过理解由C#编译器生成的代码.本章和下面两章将关注于此. 我们将用一个短小的C#程序来揭开IL的神秘面纱,并解释由编译器生成的IL代码.这样,我们就可以 ...

  7. TJU 2248. Channel Design 最小树形图

    最小树形图,測模版.... 2248.   Channel Design Time Limit: 1.0 Seconds   Memory Limit: 65536K Total Runs: 2199 ...

  8. XuLA/XuLA2

    http://www.xess.com/prods/prod048.php XuLA http://www.xess.com/prods/prod055.php XuLA2 http://www.xe ...

  9. C# httpwebrequest post 传输百分号‘%’

    转载:http://blog.csdn.net/qqstrive/article/details/8229601 通过webrequest的post传输数据的时候,如果url里面的参数带有‘%’,那么 ...

  10. glob函数的使用

    glob库函数用于Linux文件系统中路径名称的模式匹配,即查找文件系统中指定模式的路径.注意,这不是正则表达式匹配,虽然有些相似,但还是有点差别. glob函数原型       #include & ...