Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
Unity
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shane Veasy
Unity
Commits
969af149
Commit
969af149
authored
7 years ago
by
Andreia Gaita
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' into features/publish
parents
db965488
72d706a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Utility.cs
+30
-1
30 additions, 1 deletion
...UnityExtension/Assets/Editor/GitHub.Unity/Misc/Utility.cs
with
30 additions
and
1 deletion
src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Utility.cs
+
30
−
1
View file @
969af149
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text.RegularExpressions
;
using
UnityEditor
;
...
...
@@ -151,6 +152,34 @@ namespace GitHub.Unity
static
class
StreamExtensions
{
private
static
MethodInfo
loadImage
;
private
static
Func
<
Texture2D
,
MemoryStream
,
Texture2D
>
invokeLoadImage
;
static
StreamExtensions
()
{
var
t
=
typeof
(
Texture2D
).
Assembly
.
GetType
(
"UnityEngine.ImageConversion"
,
false
,
false
);
if
(
t
!=
null
)
{
// looking for ImageConversion.LoadImage(this Texture2D tex, byte[] data)
loadImage
=
t
.
GetMethods
().
FirstOrDefault
(
x
=>
x
.
Name
==
"LoadImage"
&&
x
.
GetParameters
().
Length
==
2
);
invokeLoadImage
=
(
tex
,
ms
)
=>
{
loadImage
.
Invoke
(
null
,
new
object
[]
{
tex
,
ms
.
ToArray
()
});
return
tex
;
};
}
else
{
// looking for Texture2D.LoadImage(byte[] data)
loadImage
=
typeof
(
Texture2D
).
GetMethods
().
FirstOrDefault
(
x
=>
x
.
Name
==
"LoadImage"
&&
x
.
GetParameters
().
Length
==
1
);
invokeLoadImage
=
(
tex
,
ms
)
=>
{
loadImage
.
Invoke
(
tex
,
new
object
[]
{
ms
.
ToArray
()
});
return
tex
;
};
}
}
public
static
Texture2D
ToTexture2D
(
this
Stream
input
)
{
var
buffer
=
new
byte
[
16
*
1024
];
...
...
@@ -163,7 +192,7 @@ namespace GitHub.Unity
}
var
tex
=
new
Texture2D
(
1
,
1
);
tex
.
LoadImage
(
ms
.
ToArray
()
);
tex
=
invoke
LoadImage
(
tex
,
ms
);
return
tex
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment