Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - cr4y

Pages: [1]
1
NGUI 3 Support / UIDragDropItem - Press-And-Hold bug
« on: January 20, 2015, 07:17:57 AM »
Hi,

I'd like to show something that was working correctly in 3.6.4b (and maybe 2-3 versions after that) and is buggy since then.

Example made in NGUI 3.7.9:
https://www.youtube.com/watch?v=dH_6Kl8V35M

As you can clearly see, Press and hold restriction in UIDragDropItem is not working anymore.
We spent few hours on trying to fix it, but failed. Could you make it work again?

Thanks in advance,
Kris

2
NGUI 3 Support / Re: Setting previews in Prefab Toolbar manually (png files)
« on: September 14, 2014, 06:29:09 AM »
Quick and dirty workaround in UIPrefabToolbar:

    public void Fix() {
        foreach (var item in mItems) {
            Debug.Log(item.prefab.name);
            GameObject prefab = (GameObject)PrefabUtility.InstantiatePrefab(item.prefab);
            UISnapshotPoint point = prefab.GetComponentInChildren<UISnapshotPoint>();
            if (prefab == null || point == null) continue;
            RegenerateTexture(item.prefab, point);
            DestroyImmediate(prefab);
        }
        Repaint();
    }

[...]
void OnGUI(){
  if (GUILayout.Button("Fix")) Fix();


3
NGUI 3 Support / Re: Setting previews in Prefab Toolbar manually (png files)
« on: September 14, 2014, 05:53:14 AM »
Unfortunately right now it works up to pressing play button. After going to play mode every prefab in toolbar starts to use automatic mode of snapshot again. After clicking "Update preview" on each prefab it works again.

4
Nope, there is no "LoadPreview" anywhere. What version of NGUI are you using?
Now I see your point :-)
"Load preview" was separate function in 3.6.4 I were using. Now it's merged with GeneratePreview. (Updating NGUI to 3.7.1 didn't solved our issue and we still see option to set thumbnail manually as valuable).

5
There is no LoadPreview function in NGUI. There is a GeneratePreview though.
There are both. Right now LoadPreview is being used by GeneratePreview only in free version of Unity. Anyway there is already code for loading thumbnails from files, this is why adding few lines specified in my post is enough.

This idea seems fine to me, but instead of specifying a string path, I think it makes more sense to have a Texture2D reference in its place. If set, it will be used instead. I'll add that feature.
Great idea, thanks in advance!

6
NGUI 3 Support / Setting previews in Prefab Toolbar manually (png files)
« on: August 24, 2014, 06:43:24 AM »
Hi,
For some reason UIPrefabToolbar preview generation is not working well for us. It behaves quite strange (for example we see transparent background in our button previews, while they are not transparent). Maybe we are doing something wrong. Anyway, we done something fun, and maybe it would be wise to add it to NGUI.

We wanted to be able to use png screenshots created by ourselves instead of auto generated ones.
What I have done is adding field with image path to UISnapshotPoint, and told UIPrefabToolbar to use it if not empty.

This can be useful for both Unity Free and Pro users.

Exact code modifications:
UISnapshotPoint:
  public string thumbnailPath = "";
UISnapshotPointEditor:
  (line 33)   NGUIEditorTools.DrawProperty("Path to thumbnail", serializedObject, "thumbnailPath");

UIPrefabTool:
  (top of LoadPreview function:)
  static Texture2D LoadPreview (Item item, string path="")
   {
      if(path == "") path = "Assets/NGUI/Editor/Preview/" + item.prefab.name + ".png";

  (after finding snapshot point:)
  // Try to find the snapshot point script
      if (point == null) point = child.GetComponentInChildren<UISnapshotPoint>();
      // Use snapshot from png if provided
      if (point != null && point.thumbnailPath != "") {
         item.tex = LoadPreview(item, point.thumbnailPath);
         item.dynamicTex = true;
         return;
      }


Please consider adding something like that to next version of NGUI, I'm sure it could be beneficial outside of my team too :-)

Cheers,
Kris

Pages: [1]