Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
1
1stGames
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
1stGames
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;
[DisallowMultipleComponent]
public
class
Outline
:
MonoBehaviour
{
public
class
Outline
:
MonoBehaviour
{
private
static
HashSet
<
Mesh
>
registeredMeshes
=
new
HashSet
<
Mesh
>();
public
enum
Mode
{
Color
HighlightColor
=
new
Color
(
0.1674803f
,
0.8264151f
,
0.1294197f
,
1
);
Color
DefultColor
=
Color
.
black
;
public
enum
Mode
{
OutlineAll
,
OutlineVisible
,
OutlineHidden
,
...
...
@@ -24,32 +27,39 @@ public class Outline : MonoBehaviour {
SilhouetteOnly
}
public
Mode
OutlineMode
{
public
Mode
OutlineMode
{
get
{
return
outlineMode
;
}
set
{
set
{
outlineMode
=
value
;
needsUpdate
=
true
;
}
}
public
Color
OutlineColor
{
public
Color
OutlineColor
{
get
{
return
outlineColor
;
}
set
{
set
{
outlineColor
=
value
;
needsUpdate
=
true
;
}
}
public
float
OutlineWidth
{
public
float
OutlineWidth
{
get
{
return
outlineWidth
;
}
set
{
set
{
outlineWidth
=
value
;
needsUpdate
=
true
;
}
}
[
Serializable
]
private
class
ListVector3
{
private
class
ListVector3
{
public
List
<
Vector3
>
data
;
}
...
...
@@ -80,7 +90,8 @@ public class Outline : MonoBehaviour {
private
bool
needsUpdate
;
void
Awake
()
{
void
Awake
()
{
// Cache renderers
renderers
=
GetComponentsInChildren
<
Renderer
>();
...
...
@@ -99,8 +110,10 @@ public class Outline : MonoBehaviour {
needsUpdate
=
true
;
}
void
OnEnable
()
{
foreach
(
var
renderer
in
renderers
)
{
void
OnEnable
()
{
foreach
(
var
renderer
in
renderers
)
{
// Append outline shaders
var
materials
=
renderer
.
sharedMaterials
.
ToList
();
...
...
@@ -112,33 +125,40 @@ public class Outline : MonoBehaviour {
}
}
void
OnValidate
()
{
void
OnValidate
()
{
// Update material properties
needsUpdate
=
true
;
// 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
();
bakeValues
.
Clear
();
}
// Generate smooth normals when baking is enabled
if
(
precomputeOutline
&&
bakeKeys
.
Count
==
0
)
{
if
(
precomputeOutline
&&
bakeKeys
.
Count
==
0
)
{
Bake
();
}
}
void
Update
()
{
if
(
needsUpdate
)
{
void
Update
()
{
if
(
needsUpdate
)
{
needsUpdate
=
false
;
UpdateMaterialProperties
();
}
}
void
OnDisable
()
{
foreach
(
var
renderer
in
renderers
)
{
void
OnDisable
()
{
foreach
(
var
renderer
in
renderers
)
{
// Remove outline shaders
var
materials
=
renderer
.
sharedMaterials
.
ToList
();
...
...
@@ -150,22 +170,37 @@ public class Outline : MonoBehaviour {
}
}
void
OnDestroy
()
{
void
OnDestroy
()
{
// Destroy material instances
Destroy
(
outlineMaskMaterial
);
Destroy
(
outlineFillMaterial
);
}
void
Bake
()
{
public
void
EnableHighLightColor
(
bool
enable
)
{
if
(
enable
)
{
outlineColor
=
HighlightColor
;
}
else
{
outlineColor
=
DefultColor
;
}
needsUpdate
=
true
;
}
void
Bake
()
{
// Generate smooth normals for each mesh
var
bakedMeshes
=
new
HashSet
<
Mesh
>();
foreach
(
var
meshFilter
in
GetComponentsInChildren
<
MeshFilter
>())
{
foreach
(
var
meshFilter
in
GetComponentsInChildren
<
MeshFilter
>())
{
// Skip duplicates
if
(!
bakedMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
if
(!
bakedMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
continue
;
}
...
...
@@ -177,13 +212,16 @@ public class Outline : MonoBehaviour {
}
}
void
LoadSmoothNormals
()
{
void
LoadSmoothNormals
()
{
// 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
if
(!
registeredMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
if
(!
registeredMeshes
.
Add
(
meshFilter
.
sharedMesh
))
{
continue
;
}
...
...
@@ -197,16 +235,19 @@ public class Outline : MonoBehaviour {
// Combine submeshes
var
renderer
=
meshFilter
.
GetComponent
<
Renderer
>();
if
(
renderer
!=
null
)
{
if
(
renderer
!=
null
)
{
CombineSubmeshes
(
meshFilter
.
sharedMesh
,
renderer
.
sharedMaterials
);
}
}
// 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
if
(!
registeredMeshes
.
Add
(
skinnedMeshRenderer
.
sharedMesh
))
{
if
(!
registeredMeshes
.
Add
(
skinnedMeshRenderer
.
sharedMesh
))
{
continue
;
}
...
...
@@ -218,7 +259,8 @@ public class Outline : MonoBehaviour {
}
}
List
<
Vector3
>
SmoothNormals
(
Mesh
mesh
)
{
List
<
Vector3
>
SmoothNormals
(
Mesh
mesh
)
{
// Group vertices by location
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 {
var
smoothNormals
=
new
List
<
Vector3
>(
mesh
.
normals
);
// Average normals for grouped vertices
foreach
(
var
group
in
groups
)
{
foreach
(
var
group
in
groups
)
{
// Skip single vertices
if
(
group
.
Count
()
==
1
)
{
if
(
group
.
Count
()
==
1
)
{
continue
;
}
// Calculate the average normal
var
smoothNormal
=
Vector3
.
zero
;
foreach
(
var
pair
in
group
)
{
foreach
(
var
pair
in
group
)
{
smoothNormal
+=
smoothNormals
[
pair
.
Value
];
}
smoothNormal
.
Normalize
();
// Assign smooth normal to each vertex
foreach
(
var
pair
in
group
)
{
foreach
(
var
pair
in
group
)
{
smoothNormals
[
pair
.
Value
]
=
smoothNormal
;
}
}
...
...
@@ -252,15 +298,18 @@ public class Outline : MonoBehaviour {
return
smoothNormals
;
}
void
CombineSubmeshes
(
Mesh
mesh
,
Material
[]
materials
)
{
void
CombineSubmeshes
(
Mesh
mesh
,
Material
[]
materials
)
{
// Skip meshes with a single submesh
if
(
mesh
.
subMeshCount
==
1
)
{
if
(
mesh
.
subMeshCount
==
1
)
{
return
;
}
// Skip if submesh count exceeds material count
if
(
mesh
.
subMeshCount
>
materials
.
Length
)
{
if
(
mesh
.
subMeshCount
>
materials
.
Length
)
{
return
;
}
...
...
@@ -269,12 +318,14 @@ public class Outline : MonoBehaviour {
mesh
.
SetTriangles
(
mesh
.
triangles
,
mesh
.
subMeshCount
-
1
);
}
void
UpdateMaterialProperties
()
{
void
UpdateMaterialProperties
()
{
// Apply properties according to mode
outlineFillMaterial
.
SetColor
(
"_OutlineColor"
,
outlineColor
);
switch
(
outlineMode
)
{
switch
(
outlineMode
)
{
case
Mode
.
OutlineAll
:
outlineMaskMaterial
.
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:
-
_XRMotionVectorsPass
:
1
-
_ZWrite
:
0
m_Colors
:
-
_BaseColor
:
{
r
:
0
,
g
:
1
,
b
:
0.108
99062
,
a
:
0.17384772
}
-
_Color
:
{
r
:
0
,
g
:
1
,
b
:
0.108
99224
,
a
:
0.21746951
}
-
_BaseColor
:
{
r
:
0
,
g
:
1
,
b
:
0.108
61423
,
a
:
0.11768555
}
-
_Color
:
{
r
:
0
,
g
:
1
,
b
:
0.108
64916
,
a
:
0.27467602
}
-
_EmissionColor
:
{
r
:
0
,
g
:
0
,
b
:
0
,
a
:
1
}
-
_SpecColor
:
{
r
:
0.19999996
,
g
:
0.19999996
,
b
:
0.19999996
,
a
:
1
}
m_BuildTextureStacks
:
[]
Assets/Scenes/1st/Scripts/ExperimentManager.cs
View file @
04f54655
...
...
@@ -55,6 +55,8 @@ public class ExperimentManager : MonoBehaviour
}
public
void
CloseApp
()
{
GameContextBuilder
.
Instance
.
ClearActions
();
GameContextBuilder
.
Instance
.
ClearObjective
();
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