unity3d-tile-system
unity3d-tile-system copied to clipboard
Unity 2017.2 compatibility issue
Unity keeps spamming error :
MissingFieldException: Field 'UnityEditor.PreviewRenderUtility.cameraFieldOfView' not found.
When icon for brush needs to be drawn. Seems to be fairly quick fix ( I think ) but I can't attempt to build dlls. Please consider fixing this.. This is only issue that I can see for Unity 2017 at the moment. (that gets in a way of using it nicely)
Full error code :
MissingFieldException: Field 'UnityEditor.PreviewRenderUtility.cameraFieldOfView' not found.
Rotorz.Tile.Editor.BrushPreviewRenderUtility.BeginPreviewScene ()
Rotorz.Tile.Editor.BrushPreviewRenderUtility.CreateStaticTexture (Rotorz.Tile.Brush brush, Int32 width, Int32 height)
Rotorz.Tile.Editor.BrushUtility.CreateBrushPreview (Rotorz.Tile.Brush brush, Int32 width, Int32 height)
Rotorz.Tile.Editor.BrushEditor.RenderStaticPreview (System.String assetPath, UnityEngine.Object[] subAssets, Int32 width, Int32 height)
Rotorz.Tile.Editor.AssetPreviewCache.GenerateAssetPreview (UnityEngine.Object targetObject)
Rotorz.Tile.Editor.AssetPreviewCache.GetAssetPreview (UnityEngine.Object targetObject)
Rotorz.Tile.Editor.RotorzEditorGUI.DrawBrushPreviewHelper (Rect output, Rotorz.Tile.Editor.BrushAssetRecord record, Boolean selected)
Rotorz.Tile.Editor.RotorzEditorGUI.DrawBrushPreviewWithoutFallbackLabel (Rect output, Rotorz.Tile.Editor.BrushAssetRecord record, Boolean selected)
Rotorz.Tile.Editor.BrushListControl.DrawList (UnityEngine.Event e, Rect position, Rotorz.Tile.Brush selectedBrush)
Rotorz.Tile.Editor.BrushListControl.Draw (Rect position)
Rotorz.Tile.Editor.BrushListControl.Draw (Boolean showTabs)
Rotorz.Tile.Editor.BrushPaletteWindow.DrawBrushesGUI ()
Rotorz.Tile.Editor.BrushPaletteWindow.DoGUI ()
Rotorz.Tile.Editor.RotorzWindow.OnGUI ()
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:285)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:278)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:245)
It seems that Unity renamed and encapsulated some members of their PreviewRenderUtility class. Unity's automatic upgrade feature seemed to detect and resolve the problem automatically so that workaround should work in your project as well.
This issue should be resolved by the changes made in commit 391b906.
For some reason, Unity didn't upgrade this for me... dll release with the fix is really appreciated! Thanks.
I have tried to install the package to see if I can create dlls from it... but I just can't get passed the "[email protected]: Permission denied (publickey)." error... I have solved the authentication issue.
I can get to :
$ ssh -T [email protected] Hi Pixellore! You've successfully authenticated, but GitHub does not provide shell access.
But... I get : npm install --save rotorz/unity3d-tile-system npm ERR! Error while executing: npm ERR! C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://[email protected]/rotorz/unity3d-reorderable-list.git npm ERR! npm ERR! [email protected]: Permission denied (publickey). npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists. npm ERR! npm ERR! exited with error code: 128
I have added the ssh key and all that so on... Do you need to add me to the contributor or member ? @kruncher
Tried all methods here : https://help.github.com/articles/error-permission-denied-publickey/ But still no...
If I manually run : "C:\Program Files\Git\cmd\git.EXE" ls-remote -h -t https://[email protected]/rotorz/unity3d-localized-strings.git
I get something back.. :
85f866ccde94a1afa2eaa7aa5dee385bf711e2d2 refs/heads/master c6565cf6805f72b191c3e8505609b32b4e95f1cf refs/tags/v1.0.0 85f866ccde94a1afa2eaa7aa5dee385bf711e2d2 refs/tags/v1.0.0^{}
But obviously it didn't complete the installtion.
@Pixellore hmm if you've setup an SSH key on your Github account and on your local machine; I don't see why npm wouldn't be picking it up. I am using npm version 5.4.0; could you retry using that version to see if the problem persists.
npm install -g [email protected]
Note - Installing the packages in this way will not work very well in an existing project because Unity does not maintain asset links with scripts when switching from DLL / loose source distributions. Installing the packages this way is of course useful if you want to build the DLLs yourself.
I will build the DLLs sometime today for you and add to the releases page.
I think it has got to do with read/write access to git when I don't have the write access and trying to access it by ssh instead of https.
C:\Program Files\Git\cmd\git.EXE ls-remote -h -t ssh://[email protected]/rotorz/dotnet-json.git
I don't think I can do this because I don't have the write access.. but I can with https. I was looking whole day for this issue and there are few people having the same issue over ssh. I tried to find way to force npm to access git by https (dependencies) but I was unsuccessful.
https://github.com/npm/npm/issues/3830
Please try with v5.4.0; I would be interested to know if that works for you.
Oh, yeah, I just did and it does seem to work! Interesting... something must have changed for the recent version of npm.. But please do make dll for me.. I will do my best to try and learn how to make dll from now, but there is no promise that I will succeed in that area too. XD
Here you go: https://github.com/rotorz/unity3d-tile-system/releases/tag/v1.0.2
Sorry man.. I was going to post this quick. but just tried the fixed version and got this :
Assertion failed: System is already interested in this transform, SetSystemInterested may only be called once.
UnityEditor.PreviewRenderUtility:BeginStaticPreview(Rect)
Rotorz.Tile.Editor.BrushPreviewRenderUtility:CreateStaticTexture(Brush, Int32, Int32) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/BrushPreviewRenderUtility.cs:289)
Rotorz.Tile.Editor.BrushUtility:CreateBrushPreview(Brush, Int32, Int32) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/BrushUtility.cs:155)
Rotorz.Tile.Editor.BrushEditor:RenderStaticPreview(String, Object[], Int32, Int32) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/BrushEditor.cs:93)
UnityEditor.AssetDatabase:ImportAsset(String)
Rotorz.Tile.Editor.BrushUtility:RefreshPreviewIncludingDependencies(Brush) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/BrushUtility.cs:190)
Rotorz.Tile.Editor.OrientedBrushDesigner:InsertNewVariation(BrushOrientation, Int32, Object) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/Designer/OrientedBrushDesigner.cs:1663)
Rotorz.Tile.Editor.OrientedBrushDesigner:AcceptPendingVariations(BrushOrientation) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/Designer/OrientedBrushDesigner.cs:1518)
Rotorz.Tile.Editor.OrientedBrushDesigner:DrawOrientationTrackBackground(Int32, Rect, BrushOrientation) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/Designer/OrientedBrushDesigner.cs:658)
Rotorz.Tile.Editor.OrientedBrushDesigner:DrawOrientationListBackground(Rect) (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/Designer/OrientedBrushDesigner.cs:432)
Rotorz.Tile.Editor.OrientedBrushDesigner:Section_Orientations() (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/Designer/OrientedBrushDesigner.cs:323)
Rotorz.Tile.Editor.OrientedBrushDesigner:OnGUI() (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Brush/Designer/OrientedBrushDesigner.cs:115)
Rotorz.Tile.Editor.DesignerView:Draw() (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Window/Designer/DesignerView.cs:425)
Rotorz.Tile.Editor.DesignerWindow:OnGUI_DesignerView() (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Window/Designer/DesignerWindow.cs:674)
Rotorz.Tile.Editor.DesignerWindow:DoGUI() (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/Window/Designer/DesignerWindow.cs:436)
Rotorz.Tile.Editor.RotorzWindow:OnGUI() (at Assets/Plugins/Packages/@rotorz/unity3d-tile-system/Editor/RotorzWindow.cs:194)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Another hill to climb!
This seems like a bug in Unity 2017.2.
Just tried with Unity 2.17.3.0b5 and it does the same .. damn it. Will try 2017.1
I reported this issue to Unity (Case 962008).
Thank you. I was just wondering why we can't use the preview on the brush designer window on the other previews? Because that one seems to work...
The variations that are shown in the brush designer are taken from the prefabs. The tile produced by a brush is something that doesn't exist until the brush is used. So the brush preview is generated by constructing a 1x1 tile system, painting the tile, rendering the preview, caching the preview and then using that as the preview for the brushes palette.
This is pretty much the same process that Unity undertakes when rendering the preview of a prefab.
The brush previews are constructed using the Unity API: https://docs.unity3d.com/ScriptReference/Editor.RenderStaticPreview.html
Another major advantage with using the Unity API to render the previews of brushes is that the previews will be shown in the project window (when in thumbnail view) for the brush assets.
Understood. I have desperately tried to make it work only for the orientation brush, (becasue they are the only ones I am using) by : Editing brusheditor
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
{
/*
var brush = target as Brush;
var brushDescriptor = BrushUtility.GetDescriptor(brush.GetType());
if (brushDescriptor != null && brushDescriptor.CanHavePreviewCache(brush)) {
return BrushUtility.CreateBrushPreview(target as Brush, width, height);
}
else {
return null;
}
*/
try
{
var brush = target as Brush;
var brushDescriptor = BrushUtility.GetDescriptor(brush.GetType());
if (brushDescriptor != null && brushDescriptor.CanHavePreviewCache(brush))
{
var orientatedBrush = target as OrientedBrush;
if (orientatedBrush != null)
{
var ori = orientatedBrush.DefaultOrientation;
if (ori != null)
{
if (ori.VariationCount > 0)
{
var obj = ori.GetVariation(0);
if (obj != null)
{
if (!AssetPreview.IsLoadingAssetPreviews())
{
Texture2D texture2D = AssetPreview.GetAssetPreview(obj);
if (texture2D != null)
{
return texture2D;
}
}
}
}
}
}
}
}
finally
{
}
return null;
}
}
And it does work for the first time, but then when I refresh the preview, it crashes Unity out right. :(
I guess I will need to wait for the bug to be fixed, but you know Unity... No way to tell when that is going to happen.
Maybe crash is due to the texture2d got from the AssetPreview can't be saved into the disc... I have no idea.
I have been able to reproduce the issue my end... however Unity are currently unable to reproduce the issue. They are claiming that the preview is being generated without any errors in the latest beta. I am wondering if maybe they are testing on OS X rather than Windows. Are you able to test on OS X?
Just a note; Github issues use the following syntax to markup code listings:
```{language}
```
for example,
```csharp
public sealed class Foo
{
}
```
becomes:
public sealed class Foo
{
}
No.. I am unable to test it on OS X. The issue that you are talking about, is that the AssetPreview or the original bug we have discovered?
The assertion error.
The AssetPreviewUtility is not designed to be used in the way that you are using it above. It should be used when drawing the preview to the GUI. Unity is probably crashing because the preview utility returns null over and over again whilst the preview is loaded from cache on a different thread.
If you want to use AssetPreviewUtility then you will need to register a different BrushDescriptor for oriented brushes which draws the preview using that instead.
Your implementation would return false for CanHavePreviewCache and would use AssetPreviewUtility inside its implementation of DrawPreview. When you have more than (I think it's 10) previews visible you may notice that they all start flickering. This is because AssetPreviewUtility keeps fewer previews than are visible in memory.
Copying the following may be a good starting point for you for your custom preview drawing logic: https://github.com/rotorz/unity3d-tile-system/blob/master/assets/Editor/Brush/Descriptor/OrientedBrushDescriptor.cs
You can then register your custom implementation with something like this:
[InitializeOnLoad]
public class MyCustomBrushDescriptor : BrushDescriptor
{
static MyCustomBrushDescriptor()
{
// This will override the oriented brush descriptor.
BrushUtility.RegisterDescriptor(new MyCustomBrushDescriptor());
}
public MyCustomBrushDescriptor()
: base(typeof(OrientedBrush), typeof(OrientedBrushDesigner), typeof(AliasBrushDesigner))
{
}
// ...
}
I was able to get non crashing version by doing the below : copying the texture from one texture2d to another. I know this isn't probably the way to go... but.. for for some interest sake.
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
{
/*
var brush = target as Brush;
var brushDescriptor = BrushUtility.GetDescriptor(brush.GetType());
if (brushDescriptor != null && brushDescriptor.CanHavePreviewCache(brush)) {
return BrushUtility.CreateBrushPreview(target as Brush, width, height);
}
else {
return null;
}
*/
try
{
var brush = target as Brush;
var brushDescriptor = BrushUtility.GetDescriptor(brush.GetType());
if (brushDescriptor != null && brushDescriptor.CanHavePreviewCache(brush))
{
var orientatedBrush = target as OrientedBrush;
if (orientatedBrush != null)
{
var ori = orientatedBrush.DefaultOrientation;
if (ori != null)
{
if (ori.VariationCount > 0)
{
var obj = ori.GetVariation(0);
if (obj != null)
{
if (!AssetPreview.IsLoadingAssetPreviews())
{
GameObject go = obj as GameObject;
Texture2D texture2D = AssetPreview.GetAssetPreview(go);
texture2D.Apply();
Color32[] pix = texture2D.GetPixels32();
Texture2D destTex = new Texture2D(texture2D.width, texture2D.height);
destTex.SetPixels32(pix);
destTex.Apply();
if (destTex != null)
return destTex;
}
}
}
}
}
}
}
finally
{
}
return null;
}
}
You can copy it with:
var duplicatedTexture = Instantiate(previewTexture);
The trouble is that you will often get null from AssetPreview.GetAssetPreview because if the preview hasn't already been cached it will return null until it's retrieved. Unity do this to avoid freezing the UI thread; previews just pop up when they are ready.
Thanks for the tip.
I would like to just try and build dll for my current use only without doing pull request on the git. I tried to follow the instruction on the forum, but it's been a up hill battle for me. This is even harder than I thought.. I just need to be able to build dlls without contributing to the git because the method I want to use isn't proper one and I just need dlls until Unity fixes the bug. Is there any simplier way to create dll just for myself?
I tried to run : node ./scripts/prepare-solution.js
On folder such as : E:\Pixellore\Rotorz\node_modules@rotorz\unity3d-tile-system but it gives me error :
E:\Pixellore\Rotorz\node_modules@rotorz\unity3d-tile-system>node ./scripts/prepare-solution.js module.js:529 throw err; ^
Error: Cannot find module 'glob'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.
So I don't have sln file to call MSBuild manually...
So I tried calling make on the same folder, then I get to :
Error: Cannot find module 'nunjucks'
Then I tried : make build-legacy-dlls
then .. it tried to npm install with error :
npm ERR! path E:\Pixellore\Rotorz\node_modules@rotorz\unity3d-tile-system\node_modules\fsevents\node_modules\balanced-match\package.json npm ERR! code EPERM npm ERR! errno -4048 npm ERR! syscall unlink npm ERR! Error: EPERM: operation not permitted, unlink 'E:\Pixellore\Rotorz\node_modules@rotorz\unity3d-tile-system\node_modules\fsevents\node_modules\balanced-match\package.json' npm ERR! { Error: EPERM: operation not permitted, unlink 'E:\Pixellore\Rotorz\node_modules@rotorz\unity3d-tile-system\node_modules\fsevents\node_modules\balanced-match\package.json' npm ERR! stack: 'Error: EPERM: operation not permitted, unlink 'E:\Pixellore\Rotorz\node_modules\@rotorz\unity3d-tile-system\node_modules\fsevents\node_modules\balanced-match\package.json'', npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'unlink', npm ERR! path: 'E:\Pixellore\Rotorz\node_modules\@rotorz\unity3d-tile-system\node_modules\fsevents\node_modules\balanced-match\package.json' } npm ERR! npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Saehoon\AppData\Roaming\npm-cache_logs\2017-10-25T05_49_43_756Z-debug.log mingw32-make.exe: *** [Makefile:30: install-npm] Error -4048
i did ofcourse entered cmd using admin.
Ok, no worries.. I have got around building dll problem. What I did was to just add OrientedBrushEditor.cs script with the current dlls. OrientedBrushEditor just has the above code to spit out the preview image. I am only working with the orientedbrushes so this will do for me until Unity fixes the bug. Thanks a lot for working with me till now. It's been really useful!
Unity have managed to reproduce the issue and have notified their developers about it.
Excellent. It should show up in the issue tracker soon then.. I will keep my eyes on it.
Any updates here? Any idea if the problem made it into Unity's issue tracker?
I haven't heard anything further on this issue from Unity... the ticket status is unchanged.