Cleaner ITweenPath Source
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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- source /etc/profile报错-bash: id:command is not found
由于误操作导致 source /etc/profile 报错 -bash: id:command is not found 此时,linux下很多命令到不能能用,包括vi ls 等... 可以使用 e ...
- eclipse调试(debug)的时候,出现Source not found,Edit Source Lookup Path,一闪而过
问题描述 使用Eclipse调试代码的时候,打了断点,经常出现Source not found,网上找了半天,大部分提示点击Edit Source Lookup Path,添加被调试的工程,然而往往没 ...
- Oracle使用java source调用外部程序
需求 Oracle调用第三方外部程序.Oracle使用sqluldr2快速导出大批量数据,然后用winrar压缩后发送邮件. 本文档主要实现前两步需求,发送邮件程序这里不再说明. 原码 授权 begi ...
- Perforce 与Source Insight, Visual Studio集成
转自:http://shashanzhao.com/archives/837.html 1.Perforce 首先需要为perforce设置系统环境变量,以便perforce命令行可以正常使用. 环境 ...
随机推荐
- 【BZOJ 3998】 3998: [TJOI2015]弦论 (SAM )
3998: [TJOI2015]弦论 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 2627 Solved: 881 Description 对于一 ...
- 【BZOJ 2728】 2728: [HNOI2012]与非 (线性基?)
2728: [HNOI2012]与非 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 813 Solved: 389 Description Inpu ...
- python一行代码开启http
python -m SimpleHTTPServer 8000 & 监听8000端口 浏览器用127.0.0.1:8000访问 如果出现no module named SimpleHTTPSe ...
- php 导出excel
<?phpclass Excel { var $inEncode; var $outEncode; public function _construct() { } public functio ...
- sklearn中的超参数调节
进行参数的选择是一个重要的步骤.在机器学习当中需要我们手动输入的参数叫做超参数,其余的参数需要依靠数据来进行训练,不需要我们手动设定.进行超参数选择的过程叫做调参. 进行调参应该有一下准备条件: 一个 ...
- WIFI模块 RTL8188EUS Realtek
http://item.taobao.com/item.htm?spm=a230r.1.14.24.KnooKa&id=26119704895 W12 产品是一款采用国际先进台湾瑞昱Realt ...
- FreeRTOS API
Task Creation xTaskCreate vTaskDelete Task Control vTaskDelay vTaskDelayUntil uxTaskPriorityGet vTas ...
- 利用AWR 查看SQL 执行计划
在AWR中定位到问题SQL语句后想要了解该SQL statement的具体执行计划,于是就用AWR报告中得到的SQL ID去V$SQL等几个动态性能视图中查询,但发现V$SQL或V$SQL_PLAN视 ...
- (windows)一台电脑上安装两个Mysql服务
原文:https://my.oschina.net/u/1472917/blog/410732 最近需要在一台电脑上安装两个Mysql服务,需求稍微有些奇怪,但确实很必要.本人原本为了本机测试Word ...
- Ant构建文件解析
<?xml version="1.0" encoding="UTF-8"?> <!-- 在Ant脚本中,project是这个XML文档的根结点 ...