Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱小饭呀
navmeshcomponents
提交
497243a7
N
navmeshcomponents
项目概览
爱小饭呀
/
navmeshcomponents
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
navmeshcomponents
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
497243a7
编写于
3月 20, 2017
作者:
J
Jakob Hunsballe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Coding style fixes
mostly whitespace inconsistencies
上级
e19cfb89
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
65 addition
and
67 deletion
+65
-67
Assets/NavMeshComponents/Editor/NavMeshComponentsGUIUtility.cs
...s/NavMeshComponents/Editor/NavMeshComponentsGUIUtility.cs
+29
-30
Assets/NavMeshComponents/Editor/NavMeshSurfaceEditor.cs
Assets/NavMeshComponents/Editor/NavMeshSurfaceEditor.cs
+4
-4
Assets/NavMeshComponents/Scripts/NavMeshModifier.cs
Assets/NavMeshComponents/Scripts/NavMeshModifier.cs
+9
-10
Assets/NavMeshComponents/Scripts/NavMeshModifierVolume.cs
Assets/NavMeshComponents/Scripts/NavMeshModifierVolume.cs
+11
-11
Assets/NavMeshComponents/Scripts/NavMeshSurface.cs
Assets/NavMeshComponents/Scripts/NavMeshSurface.cs
+12
-12
未找到文件。
Assets/NavMeshComponents/Editor/NavMeshComponentsGUIUtility.cs
浏览文件 @
497243a7
...
...
@@ -15,21 +15,21 @@ public static void AreaPopup(string labelName, SerializedProperty areaProperty)
if
(
areaValue
==
areaProperty
.
intValue
)
areaIndex
=
i
;
}
ArrayUtility
.
Add
(
ref
areaNames
,
""
);
ArrayUtility
.
Add
(
ref
areaNames
,
"Open Area Settings..."
);
ArrayUtility
.
Add
(
ref
areaNames
,
""
);
ArrayUtility
.
Add
(
ref
areaNames
,
"Open Area Settings..."
);
var
rect
=
EditorGUILayout
.
GetControlRect
(
true
,
EditorGUIUtility
.
singleLineHeight
);
EditorGUI
.
BeginProperty
(
rect
,
GUIContent
.
none
,
areaProperty
);
EditorGUI
.
BeginChangeCheck
();
areaIndex
=
EditorGUI
.
Popup
(
rect
,
labelName
,
areaIndex
,
areaNames
);
areaIndex
=
EditorGUI
.
Popup
(
rect
,
labelName
,
areaIndex
,
areaNames
);
if
(
EditorGUI
.
EndChangeCheck
())
{
if
(
areaIndex
>=
0
&&
areaIndex
<
areaNames
.
Length
-
2
)
areaProperty
.
intValue
=
GameObjectUtility
.
GetNavMeshAreaFromName
(
areaNames
[
areaIndex
]);
else
if
(
areaIndex
==
areaNames
.
Length
-
1
)
NavMeshEditorHelpers
.
OpenAreaSettings
();
else
if
(
areaIndex
==
areaNames
.
Length
-
1
)
NavMeshEditorHelpers
.
OpenAreaSettings
();
}
EditorGUI
.
EndProperty
();
...
...
@@ -42,34 +42,34 @@ public static void AgentTypePopup(string labelName, SerializedProperty agentType
var
agentTypeNames
=
new
string
[
count
+
2
];
for
(
var
i
=
0
;
i
<
count
;
i
++)
{
var
id
=
NavMesh
.
GetSettingsByIndex
(
i
).
agentTypeID
;
var
name
=
NavMesh
.
GetSettingsNameFromID
(
id
);
var
id
=
NavMesh
.
GetSettingsByIndex
(
i
).
agentTypeID
;
var
name
=
NavMesh
.
GetSettingsNameFromID
(
id
);
agentTypeNames
[
i
]
=
name
;
if
(
id
==
agentTypeID
.
intValue
)
index
=
i
;
}
agentTypeNames
[
count
]
=
""
;
agentTypeNames
[
count
+
1
]
=
"Open Agent Settings..."
;
agentTypeNames
[
count
+
1
]
=
"Open Agent Settings..."
;
bool
validAgentType
=
index
!=
-
1
;
if
(!
validAgentType
)
{
EditorGUILayout
.
HelpBox
(
"Agent Type invalid."
,
MessageType
.
Warning
);
EditorGUILayout
.
HelpBox
(
"Agent Type invalid."
,
MessageType
.
Warning
);
}
var
rect
=
EditorGUILayout
.
GetControlRect
(
true
,
EditorGUIUtility
.
singleLineHeight
);
EditorGUI
.
BeginProperty
(
rect
,
GUIContent
.
none
,
agentTypeID
);
EditorGUI
.
BeginChangeCheck
();
index
=
EditorGUI
.
Popup
(
rect
,
labelName
,
index
,
agentTypeNames
);
index
=
EditorGUI
.
Popup
(
rect
,
labelName
,
index
,
agentTypeNames
);
if
(
EditorGUI
.
EndChangeCheck
())
{
if
(
index
>=
0
&&
index
<
count
)
{
var
id
=
NavMesh
.
GetSettingsByIndex
(
index
).
agentTypeID
;
var
id
=
NavMesh
.
GetSettingsByIndex
(
index
).
agentTypeID
;
agentTypeID
.
intValue
=
id
;
}
else
if
(
index
==
count
+
1
)
else
if
(
index
==
count
+
1
)
{
NavMeshEditorHelpers
.
OpenAgentSettings
(-
1
);
}
...
...
@@ -87,16 +87,16 @@ public static void AgentMaskPopup(string labelName, SerializedProperty agentMask
// Contents of the dropdown box.
string
popupContent
=
""
;
if
(
agentMask
.
hasMultipleDifferentValues
)
if
(
agentMask
.
hasMultipleDifferentValues
)
popupContent
=
"\u2014"
;
else
popupContent
=
GetAgentMaskLabelName
(
agentMask
);
var
content
=
new
GUIContent
(
popupContent
);
var
popupRect
=
GUILayoutUtility
.
GetRect
(
content
,
EditorStyles
.
popup
);
var
content
=
new
GUIContent
(
popupContent
);
var
popupRect
=
GUILayoutUtility
.
GetRect
(
content
,
EditorStyles
.
popup
);
EditorGUI
.
BeginProperty
(
popupRect
,
GUIContent
.
none
,
agentMask
);
popupRect
=
EditorGUI
.
PrefixLabel
(
popupRect
,
0
,
new
GUIContent
(
labelName
));
popupRect
=
EditorGUI
.
PrefixLabel
(
popupRect
,
0
,
new
GUIContent
(
labelName
));
bool
pressed
=
GUI
.
Button
(
popupRect
,
content
,
EditorStyles
.
popup
);
if
(
pressed
)
...
...
@@ -106,36 +106,36 @@ public static void AgentMaskPopup(string labelName, SerializedProperty agentMask
var
showAll
=
show
&&
IsAll
(
agentMask
);
var
menu
=
new
GenericMenu
();
menu
.
AddItem
(
new
GUIContent
(
"None"
),
showNone
,
SetAgentMaskNone
,
agentMask
);
menu
.
AddItem
(
new
GUIContent
(
"All"
),
showAll
,
SetAgentMaskAll
,
agentMask
);
menu
.
AddSeparator
(
""
);
menu
.
AddItem
(
new
GUIContent
(
"None"
),
showNone
,
SetAgentMaskNone
,
agentMask
);
menu
.
AddItem
(
new
GUIContent
(
"All"
),
showAll
,
SetAgentMaskAll
,
agentMask
);
menu
.
AddSeparator
(
""
);
var
count
=
NavMesh
.
GetSettingsCount
();
var
count
=
NavMesh
.
GetSettingsCount
();
for
(
var
i
=
0
;
i
<
count
;
i
++)
{
var
id
=
NavMesh
.
GetSettingsByIndex
(
i
).
agentTypeID
;
var
id
=
NavMesh
.
GetSettingsByIndex
(
i
).
agentTypeID
;
var
sname
=
NavMesh
.
GetSettingsNameFromID
(
id
);
var
showSelected
=
show
&&
AgentMaskHasSelectedAgentTypeID
(
agentMask
,
id
);
var
showSelected
=
show
&&
AgentMaskHasSelectedAgentTypeID
(
agentMask
,
id
);
var
userData
=
new
object
[]
{
agentMask
,
id
,
!
showSelected
};
menu
.
AddItem
(
new
GUIContent
(
sname
),
showSelected
,
ToggleAgentMaskItem
,
userData
);
menu
.
AddItem
(
new
GUIContent
(
sname
),
showSelected
,
ToggleAgentMaskItem
,
userData
);
}
menu
.
DropDown
(
popupRect
);
menu
.
DropDown
(
popupRect
);
}
EditorGUI
.
EndProperty
();
}
public
static
GameObject
CreateAndSelectGameObject
(
string
suggestedName
,
GameObject
parent
)
public
static
GameObject
CreateAndSelectGameObject
(
string
suggestedName
,
GameObject
parent
)
{
var
parentTransform
=
parent
!=
null
?
parent
.
transform
:
null
;
var
uniqueName
=
GameObjectUtility
.
GetUniqueNameForSibling
(
parentTransform
,
suggestedName
);
var
child
=
new
GameObject
(
uniqueName
);
var
uniqueName
=
GameObjectUtility
.
GetUniqueNameForSibling
(
parentTransform
,
suggestedName
);
var
child
=
new
GameObject
(
uniqueName
);
Undo
.
RegisterCreatedObjectUndo
(
child
,
"Create "
+
uniqueName
);
Undo
.
RegisterCreatedObjectUndo
(
child
,
"Create "
+
uniqueName
);
if
(
parentTransform
!=
null
)
Undo
.
SetTransformParent
(
child
.
transform
,
parentTransform
,
"Parent "
+
uniqueName
);
Undo
.
SetTransformParent
(
child
.
transform
,
parentTransform
,
"Parent "
+
uniqueName
);
Selection
.
activeGameObject
=
child
;
...
...
@@ -256,4 +256,3 @@ static bool AgentMaskHasSelectedAgentTypeID(SerializedProperty agentMask, int ag
}
}
}
Assets/NavMeshComponents/Editor/NavMeshSurfaceEditor.cs
浏览文件 @
497243a7
...
...
@@ -46,7 +46,7 @@ struct AsyncBakeOperation
public
AsyncOperation
bakeOperation
;
}
static
List
<
AsyncBakeOperation
>
s_BakeOperations
=
new
List
<
AsyncBakeOperation
>
();
static
List
<
AsyncBakeOperation
>
s_BakeOperations
=
new
List
<
AsyncBakeOperation
>();
static
Styles
s_Styles
;
...
...
@@ -313,7 +313,7 @@ public override void OnInspectorGUI()
// Show progress for the selected targets
for
(
int
i
=
s_BakeOperations
.
Count
-
1
;
i
>=
0
;
--
i
)
{
if
(!
targets
.
Contains
(
s_BakeOperations
[
i
].
surface
))
if
(!
targets
.
Contains
(
s_BakeOperations
[
i
].
surface
))
continue
;
var
oper
=
s_BakeOperations
[
i
].
bakeOperation
;
...
...
@@ -331,7 +331,7 @@ public override void OnInspectorGUI()
if
(
GUILayout
.
Button
(
"Cancel"
,
EditorStyles
.
miniButton
))
{
var
bakeData
=
s_BakeOperations
[
i
].
bakeData
;
var
bakeData
=
s_BakeOperations
[
i
].
bakeData
;
UnityEngine
.
AI
.
NavMeshBuilder
.
Cancel
(
bakeData
);
s_BakeOperations
.
RemoveAt
(
i
);
}
...
...
@@ -349,7 +349,7 @@ static NavMeshData InitializeBakeData(NavMeshSurface surface)
var
emptySources
=
new
List
<
NavMeshBuildSource
>();
var
emptyBounds
=
new
Bounds
();
return
UnityEngine
.
AI
.
NavMeshBuilder
.
BuildNavMeshData
(
surface
.
GetBuildSettings
(),
emptySources
,
emptyBounds
,
surface
.
transform
.
position
,
surface
.
transform
.
rotation
);
,
surface
.
transform
.
position
,
surface
.
transform
.
rotation
);
}
static
void
UpdateAsyncBuildOperations
()
...
...
Assets/NavMeshComponents/Scripts/NavMeshModifier.cs
浏览文件 @
497243a7
...
...
@@ -22,34 +22,33 @@ public class NavMeshModifier : MonoBehaviour
// List of agent types the modifier is applied for.
// Special values: empty == None, m_AffectedAgents[0] =-1 == All.
[
SerializeField
]
List
<
int
>
m_AffectedAgents
=
new
List
<
int
>
(
new
int
[]
{
-
1
});
// Default value is All
List
<
int
>
m_AffectedAgents
=
new
List
<
int
>
(
new
int
[]
{
-
1
});
// Default value is All
static
readonly
List
<
NavMeshModifier
>
s_NavMeshModifiers
=
new
List
<
NavMeshModifier
>
();
static
readonly
List
<
NavMeshModifier
>
s_NavMeshModifiers
=
new
List
<
NavMeshModifier
>();
public
static
List
<
NavMeshModifier
>
activeModifiers
{
get
{
return
s_NavMeshModifiers
;
}
}
void
OnEnable
()
void
OnEnable
()
{
if
(!
s_NavMeshModifiers
.
Contains
(
this
))
s_NavMeshModifiers
.
Add
(
this
);
if
(!
s_NavMeshModifiers
.
Contains
(
this
))
s_NavMeshModifiers
.
Add
(
this
);
}
void
OnDisable
()
void
OnDisable
()
{
s_NavMeshModifiers
.
Remove
(
this
);
s_NavMeshModifiers
.
Remove
(
this
);
}
public
bool
AffectsAgentType
(
int
agentTypeID
)
public
bool
AffectsAgentType
(
int
agentTypeID
)
{
if
(
m_AffectedAgents
.
Count
==
0
)
return
false
;
if
(
m_AffectedAgents
[
0
]
==
-
1
)
return
true
;
return
m_AffectedAgents
.
IndexOf
(
agentTypeID
)
!=
-
1
;
return
m_AffectedAgents
.
IndexOf
(
agentTypeID
)
!=
-
1
;
}
}
}
Assets/NavMeshComponents/Scripts/NavMeshModifierVolume.cs
浏览文件 @
497243a7
...
...
@@ -8,11 +8,11 @@ namespace UnityEngine.AI
public
class
NavMeshModifierVolume
:
MonoBehaviour
{
[
SerializeField
]
Vector3
m_Size
=
new
Vector3
(
4.0f
,
3.0f
,
4.0f
);
Vector3
m_Size
=
new
Vector3
(
4.0f
,
3.0f
,
4.0f
);
public
Vector3
size
{
get
{
return
m_Size
;
}
set
{
m_Size
=
value
;
}
}
[
SerializeField
]
Vector3
m_Center
=
new
Vector3
(
0
,
1.0f
,
0
);
Vector3
m_Center
=
new
Vector3
(
0
,
1.0f
,
0
);
public
Vector3
center
{
get
{
return
m_Center
;
}
set
{
m_Center
=
value
;
}
}
[
SerializeField
]
...
...
@@ -22,33 +22,33 @@ public class NavMeshModifierVolume : MonoBehaviour
// List of agent types the modifier is applied for.
// Special values: empty == None, m_AffectedAgents[0] =-1 == All.
[
SerializeField
]
List
<
int
>
m_AffectedAgents
=
new
List
<
int
>
(
new
int
[]
{
-
1
});
// Default value is All
List
<
int
>
m_AffectedAgents
=
new
List
<
int
>
(
new
int
[]
{
-
1
});
// Default value is All
static
readonly
List
<
NavMeshModifierVolume
>
s_NavMeshModifiers
=
new
List
<
NavMeshModifierVolume
>
();
static
readonly
List
<
NavMeshModifierVolume
>
s_NavMeshModifiers
=
new
List
<
NavMeshModifierVolume
>();
public
static
List
<
NavMeshModifierVolume
>
activeModifiers
{
get
{
return
s_NavMeshModifiers
;
}
}
void
OnEnable
()
void
OnEnable
()
{
if
(!
s_NavMeshModifiers
.
Contains
(
this
))
s_NavMeshModifiers
.
Add
(
this
);
if
(!
s_NavMeshModifiers
.
Contains
(
this
))
s_NavMeshModifiers
.
Add
(
this
);
}
void
OnDisable
()
void
OnDisable
()
{
s_NavMeshModifiers
.
Remove
(
this
);
s_NavMeshModifiers
.
Remove
(
this
);
}
public
bool
AffectsAgentType
(
int
agentTypeID
)
public
bool
AffectsAgentType
(
int
agentTypeID
)
{
if
(
m_AffectedAgents
.
Count
==
0
)
return
false
;
if
(
m_AffectedAgents
[
0
]
==
-
1
)
return
true
;
return
m_AffectedAgents
.
IndexOf
(
agentTypeID
)
!=
-
1
;
return
m_AffectedAgents
.
IndexOf
(
agentTypeID
)
!=
-
1
;
}
}
}
Assets/NavMeshComponents/Scripts/NavMeshSurface.cs
浏览文件 @
497243a7
...
...
@@ -149,7 +149,7 @@ public void Bake()
}
var
data
=
NavMeshBuilder
.
BuildNavMeshData
(
GetBuildSettings
(),
sources
,
sourcesBounds
,
transform
.
position
,
transform
.
rotation
);
sources
,
sourcesBounds
,
transform
.
position
,
transform
.
rotation
);
if
(
data
!=
null
)
{
...
...
@@ -313,18 +313,18 @@ Bounds CalculateWorldBounds(List<NavMeshBuildSource> sources)
switch
(
src
.
shape
)
{
case
NavMeshBuildSourceShape
.
Mesh
:
{
var
m
=
src
.
sourceObject
as
Mesh
;
result
.
Encapsulate
(
GetWorldBounds
(
worldToLocal
*
src
.
transform
,
m
.
bounds
));
break
;
}
{
var
m
=
src
.
sourceObject
as
Mesh
;
result
.
Encapsulate
(
GetWorldBounds
(
worldToLocal
*
src
.
transform
,
m
.
bounds
));
break
;
}
case
NavMeshBuildSourceShape
.
Terrain
:
{
// Terrain pivot is lower/left corner - shift bounds accordingly
var
t
=
src
.
sourceObject
as
TerrainData
;
result
.
Encapsulate
(
GetWorldBounds
(
worldToLocal
*
src
.
transform
,
new
Bounds
(
0.5f
*
t
.
size
,
t
.
size
)));
break
;
}
{
// Terrain pivot is lower/left corner - shift bounds accordingly
var
t
=
src
.
sourceObject
as
TerrainData
;
result
.
Encapsulate
(
GetWorldBounds
(
worldToLocal
*
src
.
transform
,
new
Bounds
(
0.5f
*
t
.
size
,
t
.
size
)));
break
;
}
case
NavMeshBuildSourceShape
.
Box
:
case
NavMeshBuildSourceShape
.
Sphere
:
case
NavMeshBuildSourceShape
.
Capsule
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录