資源簡介
unity3d的2d光影插件
unity3d的2d光影插件
unity3d的2d光影插件

代碼片段和文件信息
using?UnityEngine;
using?System.Collections;
using?System.Collections.Generic;
namespace?LOS?{
///?
///?LOS?camera.?
///?Needs?to?be?placed?in?a?camera?for?the?system?to?work.
///?
[RequireComponent?(typeof(Camera))]
public?class?LOSCamera?:?LOSobjectbase?{
[HideInInspector]
public?Vector2?halfViewboxSize;
private?List?_viewbox;
private?Camera?_camera;
public?List?viewbox?{
get?{
if?(_viewbox?==?null)?{
_viewbox?=?new?List();
for?(int?i=0;?i<4;?i++)?{
_viewbox.Add(new?ViewBoxLine());
}
UpdateViewingBox();
}
return?_viewbox;
}
}
public?List?viewboxCorners?{
get?{
List?result?=?new?List();
foreach?(var?line?in?viewbox)?{
result.Add(line.end);
}
return?result;
}
}
public?void?UpdateViewingBox?()?{
Vector2?screenSize?=?SHelper.GetScreenSizeInWorld(unityCamera);
halfViewboxSize?=?screenSize?/?2?*?LOSManager.instance.viewboxExtension;
Vector2?upperRight?=?new?Vector2(halfViewboxSize.x?halfViewboxSize.y)?+?SMath.Vec3ToVec2(_trans.position);
Vector2?upperLeft?=?new?Vector2(-halfViewboxSize.x?halfViewboxSize.y)?+?SMath.Vec3ToVec2(_trans.position);
Vector2?lowerLeft?=?new?Vector2(-halfViewboxSize.x?-halfViewboxSize.y)?+?SMath.Vec3ToVec2(_trans.position);
Vector2?lowerRight?=?new?Vector2(halfViewboxSize.x?-halfViewboxSize.y)?+?SMath.Vec3ToVec2(_trans.position);
viewbox[0].SetStartEnd(lowerRight?upperRight); //?right
viewbox[1].SetStartEnd(upperRight?upperLeft); //?up
viewbox[2].SetStartEnd(upperLeft?lowerLeft); //?left
viewbox[3].SetStartEnd(lowerLeft?lowerRight); //?down
}
public?Camera?unityCamera?{
get?{
if?(_camera?==?null)?{
_camera?=?GetComponent();
}
return?_camera;
}
}
public?Vector3?GetCollisionPointWithViewBox?(Vector3?origin?Vector3?direction)?{
Vector3?point?=?Vector3.zero;
foreach?(var?line?in?viewbox)?{
Vector2?q?=?line.start;
Vector2?s?=?line.end?-?line.start;
Vector2?p?=?SMath.Vec3ToVec2(origin);
Vector2?r?=?SMath.Vec3ToVec2(direction);
//?The?intersection?is?where?q?+?u*s?==?p?+?t*r?and?0?<=?u?<=?1?&&?0?<=?t
//?t?=?(q???p)?×?s?/?(r?×?s)
//?u?=?(q???p)?×?r?/?(r?×?s)
float?crossRS?=?SMath.CrossProduct2D(r?s);
float?crossQP_S?=?SMath.CrossProduct2D(q?-?p?s);
float?crossQP_R?=?SMath.CrossProduct2D(q?-?p?r);
if?(crossRS?==?0)?{
//?TODO:?other?situations
}
else?{
float?t?=?crossQP_S?/?crossRS;
float?u?=?crossQP_R?/?crossRS;
if?(0?<=?u?&&?u?<=?1?&&?0?<=?t)?{
point?=?q?+?u?*?s;
break;
}
}
}
return?point;
}
//?Works?in?counter-clock?wise?pointA?is?the?one?with?smaller?angle?against?vector?(1?0)
public?List?GetViewboxCornersBetweenPoints?(Vector3?pointA?Vector3?pointB?Vector3?origin?bool?give4CornersWhenAEqualB)?{
poin
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\
?????文件?????????107??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core.me
?????目錄???????????0??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\
?????文件?????????107??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event.me
?????目錄???????????0??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\
?????文件????????2571??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\LOSEventManager.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\LOSEventManager.cs.me
?????文件????????3586??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\LOSEventSource.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\LOSEventSource.cs.me
?????文件????????2015??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\LOSEventTrigger.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\Event\LOSEventTrigger.cs.me
?????文件????????4879??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSCamera.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSCamera.cs.me
?????文件???????20743??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSFullScreenLight.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSFullScreenLight.cs.me
?????文件???????11749??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSLightba
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSLightba
?????文件????????5532??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSManager.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSManager.cs.me
?????文件?????????882??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSob
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSob
?????文件????????1369??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSObstacle.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSObstacle.cs.me
?????文件????????7345??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSRadialLight.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Core\LOSRadialLight.cs.me
?????文件?????????107??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Editor.me
?????目錄???????????0??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Editor\
?????文件?????????942??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Editor\LOSFullScreenLightEditor.cs
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Editor\LOSFullScreenLightEditor.cs.me
?????文件????????2011??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Editor\LOSLightba
?????文件?????????178??2015-06-18?12:09??2D-Light-of-Sight-Unity-master\Editor\LOSLightba
............此處省略103個文件信息
評論
共有 條評論