Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
Vlab
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abdulrahman Mohammed
Vlab
Commits
04f54655
Commit
04f54655
authored
Oct 27, 2025
by
Abdulrahman Mohammed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some erros
parent
73de2004
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1854 additions
and
667 deletions
+1854
-667
Outline.cs
Assets/QuickOutline/Scripts/Outline.cs
+268
-217
Highlight.mat
Assets/Scenes/1st/Material/Highlight.mat
+2
-2
ExperimentManager.cs
Assets/Scenes/1st/Scripts/ExperimentManager.cs
+2
-0
Light.asset
Assets/Scenes/Test 2/Font/TSHakwaty/Light.asset
+129
-21
test.unity
Assets/Scenes/Test 2/test.unity
+1453
-427
No files found.
Assets/QuickOutline/Scripts/Outline.cs
View file @
04f54655
...
@@ -13,10 +13,13 @@ using UnityEngine;
...
@@ -13,10 +13,13 @@ using UnityEngine;
[DisallowMultipleComponent]
[DisallowMultipleComponent]
public
class
Outline
:
MonoBehaviour
{
public
class
Outline
:
MonoBehaviour
{
private
static
HashSet
<
Mesh
>
registeredMeshes
=
new
HashSet
<
Mesh
>();
private
static
HashSet
<
Mesh
>
registeredMeshes
=
new
HashSet
<
Mesh
>();
Color
HighlightColor
=
new
Color
(
0.1674803f
,
0.8264151f
,
0.1294197f
,
1
);
public
enum
Mode
{
Color
DefultColor
=
Color
.
black
;
public
enum
Mode
{
OutlineAll
,
OutlineAll
,
OutlineVisible
,
OutlineVisible
,
OutlineHidden
,
OutlineHidden
,
...
@@ -24,32 +27,39 @@ public class Outline : MonoBehaviour {
...
@@ -24,32 +27,39 @@ public class Outline : MonoBehaviour {
SilhouetteOnly
SilhouetteOnly
}
}
public
Mode
OutlineMode
{
public
Mode
OutlineMode
{
get
{
return
outlineMode
;
}
get
{
return
outlineMode
;
}
set
{
set
{
outlineMode
=
value
;
outlineMode
=
value
;
needsUpdate
=
true
;
needsUpdate
=
true
;
}
}
}
}
public
Color
OutlineColor
{
public
Color
OutlineColor
{
get
{
return
outlineColor
;
}
get
{
return
outlineColor
;
}
set
{
set
{
outlineColor
=
value
;
outlineColor
=
value
;
needsUpdate
=
true
;
needsUpdate
=
true
;
}
}
}
}
public
float
OutlineWidth
{
public
float
OutlineWidth
{
get
{
return
outlineWidth
;
}
get
{
return
outlineWidth
;
}
set
{
set
{
outlineWidth
=
value
;
outlineWidth
=
value
;
needsUpdate
=
true
;
needsUpdate
=
true
;
}
}
}
}
[
Serializable
]
[
Serializable
]
private
class
ListVector3
{
private
class
ListVector3
{
public
List
<
Vector3
>
data
;
public
List
<
Vector3
>
data
;
}
}
...
@@ -80,7 +90,8 @@ public class Outline : MonoBehaviour {
...
@@ -80,7 +90,8 @@ public class Outline : MonoBehaviour {
private
bool
needsUpdate
;
private
bool
needsUpdate
;
void
Awake
()
{
void
Awake
()
{
// Cache renderers
// Cache renderers
renderers
=
GetComponentsInChildren
<
Renderer
>();
renderers
=
GetComponentsInChildren
<
Renderer
>();
...
@@ -99,8 +110,10 @@ public class Outline : MonoBehaviour {
...
@@ -99,8 +110,10 @@ public class Outline : MonoBehaviour {
needsUpdate
=
true
;
needsUpdate
=
true
;
}
}
void
OnEnable
()
{
void
OnEnable
()
foreach
(
var
renderer
in
renderers
)
{
{
foreach
(
var
renderer
in
renderers
)
{
// Append outline shaders
// Append outline shaders
var
materials
=
renderer
.
sharedMaterials
.
ToList
();
var
materials
=
renderer
.
sharedMaterials
.
ToList
();
...
@@ -112,33 +125,40 @@ public class Outline : MonoBehaviour {
...
@@ -112,33 +125,40 @@ public class Outline : MonoBehaviour {
}
}
}
}
void
OnValidate
()
{
void
OnValidate
()
{
// Update material properties
// Update material properties
needsUpdate
=
true
;
needsUpdate
=
true
;
// Clear cache when baking is disabled or corrupted
// Clear cache when baking is disabled or corrupted
if
(!
precomputeOutline
&&
bakeKeys
.
Count
!=
0
||
bakeKeys
.
Count
!=
bakeValues
.
Count
)
{
if
(!
precomputeOutline
&&
bakeKeys
.
Count
!=
0
||
bakeKeys
.
Count
!=
bakeValues
.
Count
)
{
bakeKeys
.
Clear
();
bakeKeys
.
Clear
();
bakeValues
.
Clear
();
bakeValues
.
Clear
();
}
}
// Generate smooth normals when baking is enabled
// Generate smooth normals when baking is enabled
if
(
precomputeOutline
&&
bakeKeys
.
Count
==
0
)
{
if
(
precomputeOutline
&&
bakeKeys
.
Count
==
0
)
{
Bake
();
Bake
();
}
}
}
}
void
Update
()
{
void
Update
()
if
(
needsUpdate
)
{
{
if
(
needsUpdate
)
{
needsUpdate
=
false
;
needsUpdate
=
false
;
UpdateMaterialProperties
();
UpdateMaterialProperties
();
}
}
}
}
void
OnDisable
()
{
void
OnDisable
()
foreach
(
var
renderer
in
renderers
)
{
{
foreach
(
var
renderer
in
renderers
)
{
// Remove outline shaders
// Remove outline shaders
var
materials
=
renderer
.
sharedMaterials
.
ToList
();
var
materials
=
renderer
.
sharedMaterials
.
ToList
();
...
@@ -150,22 +170,37 @@ public class Outline : MonoBehaviour {
...
@@ -150,22 +170,37 @@ public class Outline : MonoBehaviour {
}
}
}
}
void
OnDestroy
()
{
void
OnDestroy
()
{
// Destroy material instances
// Destroy material instances
Destroy
(
outlineMaskMaterial
);
Destroy
(
outlineMaskMaterial
);
Destroy
(
outlineFillMaterial
);
Destroy
(
outlineFillMaterial
);
}
}
public
void
EnableHighLightColor
(
bool
enable
)
void
Bake
()
{
{
if
(
enable
)
{
outlineColor
=
HighlightColor
;
}
else
{
outlineColor
=
DefultColor
;
}
needsUpdate
=
true
;
}
void
Bake
()
{
// Generate smooth normals for each mesh
// Generate smooth normals for each mesh
var
bakedMeshes
=
new
HashSet
<
Mesh
>();
var
bakedMeshes
=
new
HashSet
<
Mesh
>();
foreach
(
var
meshFilter
in
GetComponentsInChildren
<
MeshFilter
>())
{
foreach
(
var
meshFilter
in
GetComponentsInChildren
<
MeshFilter
>())
{
// Skip duplicates
// Skip duplicates
if
(!
bakedMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
if
(!
bakedMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
continue
;
continue
;
}
}
...
@@ -177,13 +212,16 @@ public class Outline : MonoBehaviour {
...
@@ -177,13 +212,16 @@ public class Outline : MonoBehaviour {
}
}
}
}
void
LoadSmoothNormals
()
{
void
LoadSmoothNormals
()
{
// Retrieve or generate smooth normals
// Retrieve or generate smooth normals
foreach
(
var
meshFilter
in
GetComponentsInChildren
<
MeshFilter
>())
{
foreach
(
var
meshFilter
in
GetComponentsInChildren
<
MeshFilter
>())
{
// Skip if smooth normals have already been adopted
// Skip if smooth normals have already been adopted
if
(!
registeredMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
if
(!
registeredMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
continue
;
continue
;
}
}
...
@@ -197,16 +235,19 @@ public class Outline : MonoBehaviour {
...
@@ -197,16 +235,19 @@ public class Outline : MonoBehaviour {
// Combine submeshes
// Combine submeshes
var
renderer
=
meshFilter
.
GetComponent
<
Renderer
>();
var
renderer
=
meshFilter
.
GetComponent
<
Renderer
>();
if
(
renderer
!=
null
)
{
if
(
renderer
!=
null
)
{
CombineSubmeshes
(
meshFilter
.
sharedMesh
,
renderer
.
sharedMaterials
);
CombineSubmeshes
(
meshFilter
.
sharedMesh
,
renderer
.
sharedMaterials
);
}
}
}
}
// Clear UV3 on skinned mesh renderers
// Clear UV3 on skinned mesh renderers
foreach
(
var
skinnedMeshRenderer
in
GetComponentsInChildren
<
SkinnedMeshRenderer
>())
{
foreach
(
var
skinnedMeshRenderer
in
GetComponentsInChildren
<
SkinnedMeshRenderer
>())
{
// Skip if UV3 has already been reset
// Skip if UV3 has already been reset
if
(!
registeredMeshes
.
Add
(
skinnedMeshRenderer
.
sharedMesh
))
{
if
(!
registeredMeshes
.
Add
(
skinnedMeshRenderer
.
sharedMesh
))
{
continue
;
continue
;
}
}
...
@@ -218,7 +259,8 @@ public class Outline : MonoBehaviour {
...
@@ -218,7 +259,8 @@ public class Outline : MonoBehaviour {
}
}
}
}
List
<
Vector3
>
SmoothNormals
(
Mesh
mesh
)
{
List
<
Vector3
>
SmoothNormals
(
Mesh
mesh
)
{
// Group vertices by location
// Group vertices by location
var
groups
=
mesh
.
vertices
.
Select
((
vertex
,
index
)
=>
new
KeyValuePair
<
Vector3
,
int
>(
vertex
,
index
)).
GroupBy
(
pair
=>
pair
.
Key
);
var
groups
=
mesh
.
vertices
.
Select
((
vertex
,
index
)
=>
new
KeyValuePair
<
Vector3
,
int
>(
vertex
,
index
)).
GroupBy
(
pair
=>
pair
.
Key
);
...
@@ -227,24 +269,28 @@ public class Outline : MonoBehaviour {
...
@@ -227,24 +269,28 @@ public class Outline : MonoBehaviour {
var
smoothNormals
=
new
List
<
Vector3
>(
mesh
.
normals
);
var
smoothNormals
=
new
List
<
Vector3
>(
mesh
.
normals
);
// Average normals for grouped vertices
// Average normals for grouped vertices
foreach
(
var
group
in
groups
)
{
foreach
(
var
group
in
groups
)
{
// Skip single vertices
// Skip single vertices
if
(
group
.
Count
()
==
1
)
{
if
(
group
.
Count
()
==
1
)
{
continue
;
continue
;
}
}
// Calculate the average normal
// Calculate the average normal
var
smoothNormal
=
Vector3
.
zero
;
var
smoothNormal
=
Vector3
.
zero
;
foreach
(
var
pair
in
group
)
{
foreach
(
var
pair
in
group
)
{
smoothNormal
+=
smoothNormals
[
pair
.
Value
];
smoothNormal
+=
smoothNormals
[
pair
.
Value
];
}
}
smoothNormal
.
Normalize
();
smoothNormal
.
Normalize
();
// Assign smooth normal to each vertex
// Assign smooth normal to each vertex
foreach
(
var
pair
in
group
)
{
foreach
(
var
pair
in
group
)
{
smoothNormals
[
pair
.
Value
]
=
smoothNormal
;
smoothNormals
[
pair
.
Value
]
=
smoothNormal
;
}
}
}
}
...
@@ -252,15 +298,18 @@ public class Outline : MonoBehaviour {
...
@@ -252,15 +298,18 @@ public class Outline : MonoBehaviour {
return
smoothNormals
;
return
smoothNormals
;
}
}
void
CombineSubmeshes
(
Mesh
mesh
,
Material
[]
materials
)
{
void
CombineSubmeshes
(
Mesh
mesh
,
Material
[]
materials
)
{
// Skip meshes with a single submesh
// Skip meshes with a single submesh
if
(
mesh
.
subMeshCount
==
1
)
{
if
(
mesh
.
subMeshCount
==
1
)
{
return
;
return
;
}
}
// Skip if submesh count exceeds material count
// Skip if submesh count exceeds material count
if
(
mesh
.
subMeshCount
>
materials
.
Length
)
{
if
(
mesh
.
subMeshCount
>
materials
.
Length
)
{
return
;
return
;
}
}
...
@@ -269,12 +318,14 @@ public class Outline : MonoBehaviour {
...
@@ -269,12 +318,14 @@ public class Outline : MonoBehaviour {
mesh
.
SetTriangles
(
mesh
.
triangles
,
mesh
.
subMeshCount
-
1
);
mesh
.
SetTriangles
(
mesh
.
triangles
,
mesh
.
subMeshCount
-
1
);
}
}
void
UpdateMaterialProperties
()
{
void
UpdateMaterialProperties
()
{
// Apply properties according to mode
// Apply properties according to mode
outlineFillMaterial
.
SetColor
(
"_OutlineColor"
,
outlineColor
);
outlineFillMaterial
.
SetColor
(
"_OutlineColor"
,
outlineColor
);
switch
(
outlineMode
)
{
switch
(
outlineMode
)
{
case
Mode
.
OutlineAll
:
case
Mode
.
OutlineAll
:
outlineMaskMaterial
.
SetFloat
(
"_ZTest"
,
(
float
)
UnityEngine
.
Rendering
.
CompareFunction
.
Always
);
outlineMaskMaterial
.
SetFloat
(
"_ZTest"
,
(
float
)
UnityEngine
.
Rendering
.
CompareFunction
.
Always
);
outlineFillMaterial
.
SetFloat
(
"_ZTest"
,
(
float
)
UnityEngine
.
Rendering
.
CompareFunction
.
Always
);
outlineFillMaterial
.
SetFloat
(
"_ZTest"
,
(
float
)
UnityEngine
.
Rendering
.
CompareFunction
.
Always
);
...
...
Assets/Scenes/1st/Material/Highlight.mat
View file @
04f54655
...
@@ -135,8 +135,8 @@ Material:
...
@@ -135,8 +135,8 @@ Material:
-
_XRMotionVectorsPass
:
1
-
_XRMotionVectorsPass
:
1
-
_ZWrite
:
0
-
_ZWrite
:
0
m_Colors
:
m_Colors
:
-
_BaseColor
:
{
r
:
0
,
g
:
1
,
b
:
0.108
99062
,
a
:
0.17384772
}
-
_BaseColor
:
{
r
:
0
,
g
:
1
,
b
:
0.108
61423
,
a
:
0.11768555
}
-
_Color
:
{
r
:
0
,
g
:
1
,
b
:
0.108
99224
,
a
:
0.21746951
}
-
_Color
:
{
r
:
0
,
g
:
1
,
b
:
0.108
64916
,
a
:
0.27467602
}
-
_EmissionColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
-
_EmissionColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
-
_SpecColor
:
{
r
:
0.19999996
,
g
:
0.19999996
,
b
:
0.19999996
,
a
:
1
}
-
_SpecColor
:
{
r
:
0.19999996
,
g
:
0.19999996
,
b
:
0.19999996
,
a
:
1
}
m_BuildTextureStacks
:
[]
m_BuildTextureStacks
:
[]
Assets/Scenes/1st/Scripts/ExperimentManager.cs
View file @
04f54655
...
@@ -55,6 +55,8 @@ public class ExperimentManager : MonoBehaviour
...
@@ -55,6 +55,8 @@ public class ExperimentManager : MonoBehaviour
}
}
public
void
CloseApp
()
public
void
CloseApp
()
{
{
GameContextBuilder
.
Instance
.
ClearActions
();
GameContextBuilder
.
Instance
.
ClearObjective
();
Application
.
Quit
();
Application
.
Quit
();
}
}
}
}
Assets/Scenes/Test 2/Font/TSHakwaty/Light.asset
View file @
04f54655
This diff is collapsed.
Click to expand it.
Assets/Scenes/Test 2/test.unity
View file @
04f54655
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment