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 - blackant

Pages: [1] 2
1
NGUI 3 Support / Re: NGUI Virtual Joystick
« on: December 15, 2014, 09:52:44 AM »
Hi Guys,

i'm trying to use this script i fund on this post, but i get an error while unity compile it


Error:
Assets/NGUI/Scripts/Interaction/UIJoyStick.cs(14,27): error CS0246: The type or namespace name `IgnoreTimeScale' could not be found. Are you missing a using directive or an assembly reference?


  1. //----------------------------------------------
  2. //            NGUI: Next-Gen UI kit
  3. // Copyright © 2011-2013 Tasharen Entertainment
  4. //----------------------------------------------
  5.  
  6. using UnityEngine;
  7. using System.Collections;
  8.  
  9. /// <summary>
  10. /// Allows dragging of the specified target object by mouse or touch, optionally limiting it to be within the UIPanel's clipped rectangle.
  11. /// </summary>
  12.  
  13. [AddComponentMenu("NGUI/Interaction/JoyStick")]
  14. public class UIJoyStick : IgnoreTimeScale
  15. {
  16.         public enum DragEffect
  17.         {
  18.                 None,
  19.                 Momentum,
  20.                 MomentumAndSpring,
  21.         }
  22.        
  23.         public float joyStickPosX;
  24.         public float joyStickPosY;
  25.         private float posDivision;
  26.        
  27.         /// <summary>
  28.         /// Target object that will be dragged.
  29.         /// </summary>
  30.        
  31.         public Transform target;
  32.        
  33.         /// <summary>
  34.         /// Scale value applied to the drag delta. Set X or Y to 0 to disallow dragging in that direction.
  35.         /// </summary>
  36.        
  37.         private Vector3 scale = Vector3.one;
  38.        
  39.         /// <summary>
  40.         /// Effect the scroll wheel will have on the momentum.
  41.         /// </summary>
  42.        
  43.         public float scrollWheelFactor = 0f;
  44.        
  45.         /// <summary>
  46.         /// Whether the dragging will be restricted to be within the parent panel's bounds.
  47.         /// </summary>
  48.        
  49.         public bool restrictWithinPanel = false;
  50.        
  51.         /// <summary>
  52.         /// 限制按鈕移動半徑範圍
  53.         /// The clamp radius.
  54.         /// </summary>
  55.         public float ClampRadius = 100.0f;
  56.        
  57.         /// <summary>
  58.         /// How much momentum gets applied when the press is released after dragging.
  59.         /// </summary>
  60.        
  61.         Plane mPlane;
  62.         Vector3 mLastPos;
  63.         UIPanel mPanel;
  64.         bool mPressed = false;
  65.         Vector3 mMomentum = Vector3.zero;
  66.         float mScroll = 0f;
  67.         Bounds mBounds;
  68.        
  69.         void Awake ()
  70.         {
  71.                 posDivision = 1 / ClampRadius;
  72.         }
  73.        
  74.         /// <summary>
  75.         /// Find the panel responsible for this object.
  76.         /// </summary>
  77.        
  78.         void FindPanel ()
  79.         {
  80.                 mPanel = (target != null) ? UIPanel.Find(target.transform, false) : null;
  81.                 if (mPanel == null) restrictWithinPanel = false;
  82.         }
  83.        
  84.         /// <summary>
  85.         /// Create a plane on which we will be performing the dragging.
  86.         /// </summary>
  87.         void OnHover (bool Hover)
  88.         {
  89.                 //print ("!!");
  90.         }
  91.         void OnPress (bool pressed)
  92.         {
  93.                 if (enabled && NGUITools.GetActive(gameObject) && target != null)
  94.                 {
  95.                         mPressed = pressed;
  96.                        
  97.                         if (pressed)
  98.                         {
  99.                                 if (restrictWithinPanel && mPanel == null) FindPanel();
  100.                                
  101.                                 // Calculate the bounds
  102.                                 if (restrictWithinPanel) mBounds = NGUIMath.CalculateRelativeWidgetBounds(mPanel.cachedTransform, target);
  103.                                
  104.                                 // Remove all momentum on press
  105.                                 mMomentum = Vector3.zero;
  106.                                 mScroll = 0f;
  107.                                
  108.                                 // Disable the spring movement
  109.                                 SpringPosition sp = target.GetComponent<SpringPosition>();
  110.                                 if (sp != null) sp.enabled = false;
  111.                                
  112.                                 // Remember the hit position
  113.                                 mLastPos = UICamera.lastHit.point;
  114.                                
  115.                                 // Create the plane to drag along
  116.                                 Transform trans = UICamera.currentCamera.transform;
  117.                                 mPlane = new Plane((mPanel != null ? mPanel.cachedTransform.rotation : trans.rotation) * Vector3.back, mLastPos);
  118.                         }
  119.                         else if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
  120.                         {
  121.                                 mPanel.ConstrainTargetToBounds(target, ref mBounds, false);
  122.                         }
  123.                         if (!pressed)
  124.                         {
  125.                                 StartCoroutine("SpringPositionUpdate");
  126.                                
  127.                         }
  128.                 }
  129.         }
  130.        
  131.         /// <summary>
  132.         /// Drag the object along the plane.
  133.         /// </summary>
  134.        
  135.         void OnDrag (Vector2 delta)
  136.         {
  137.                 //print ("haha");
  138.                 if (enabled && NGUITools.GetActive(gameObject) && target != null)
  139.                 {
  140.                         UICamera.currentTouch.clickNotification = UICamera.ClickNotification.BasedOnDelta;
  141.                        
  142.                         Ray ray = UICamera.currentCamera.ScreenPointToRay(UICamera.currentTouch.pos);
  143.                         float dist = 0f;
  144.                        
  145.                         if (mPlane.Raycast(ray, out dist))
  146.                         {
  147.                                 //print (ray.GetPoint(dist).x+","+ray.GetPoint(dist).y);
  148.                                 Vector3 currentPos = ray.GetPoint(dist);
  149.                                 mLastPos = currentPos;
  150.                                
  151.                                 // We want to constrain the UI to be within bounds
  152.                                 target.position = currentPos;                  
  153.                                 // 限制虛擬搖桿目標移動半徑
  154.                                 target.transform.localPosition = new Vector3(Vector3.ClampMagnitude(target.transform.localPosition, ClampRadius).x, Vector3.ClampMagnitude(target.transform.localPosition, ClampRadius).y, 0);
  155.                                 // 獲取目標
  156.                                 joyStickPosX = target.transform.localPosition.x * posDivision;
  157.                                 joyStickPosY = target.transform.localPosition.y * posDivision;
  158.                         }
  159.                 }
  160.         }
  161.        
  162.         /// <summary>
  163.         /// Apply the dragging momentum.
  164.         /// </summary>
  165.        
  166.         void LateUpdate ()
  167.         {
  168.                 float delta = UpdateRealTimeDelta();
  169.                 if (target == null) return;
  170.                
  171.                 if (mPressed)
  172.                 {
  173.                         // Disable the spring movement
  174.                         SpringPosition sp = target.GetComponent<SpringPosition>();
  175.                         if (sp != null) sp.enabled = false;
  176.                         mScroll = 0f;
  177.                 }
  178.                 else
  179.                 {
  180.                         mMomentum += scale * (-mScroll * 0.05f);
  181.                         mScroll = NGUIMath.SpringLerp(mScroll, 0f, 20f, delta);
  182.                        
  183.                         if (mMomentum.magnitude > 0.0001f)
  184.                         {
  185.                                 // Apply the momentum
  186.                                 if (mPanel == null) FindPanel();
  187.                                
  188.                                 if (mPanel != null)
  189.                                 {
  190.                                         target.position += NGUIMath.SpringDampen(ref mMomentum, 9f, delta);
  191.                                        
  192.                                         if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
  193.                                         {
  194.                                                 mBounds = NGUIMath.CalculateRelativeWidgetBounds(mPanel.cachedTransform, target);
  195.                                                
  196.                                                
  197.                                         }
  198.                                         return;
  199.                                 }
  200.                         }
  201.                         else mScroll = 0f;
  202.                 }
  203.                
  204.                 // Dampen the momentum
  205.                 NGUIMath.SpringDampen(ref mMomentum, 9f, delta);
  206.         }
  207.        
  208.         /// <summary>
  209.         /// If the object should support the scroll wheel, do it.
  210.         /// </summary>
  211.        
  212.         void OnScroll (float delta)
  213.         {
  214.                 if (enabled && NGUITools.GetActive(gameObject))
  215.                 {
  216.                         if (Mathf.Sign(mScroll) != Mathf.Sign(delta)) mScroll = 0f;
  217.                         mScroll += delta * scrollWheelFactor;
  218.                 }
  219.         }      
  220.        
  221.         //public delegate void OnFinished (UIJoyStick);
  222.         /// <summary>
  223.         /// Target position to tween to.
  224.         /// </summary>
  225.        
  226.         private Vector3 targetPosition = Vector3.zero;
  227.        
  228.         /// <summary>
  229.         /// How strong is the pull of the spring. Higher value means it gets to the target faster.
  230.         /// </summary>
  231.        
  232.         public float strength = 10f;
  233.        
  234.        
  235.         /// <summary>
  236.         /// Whether the time scale will be ignored. Generally UI components should set it to 'true'.
  237.         /// </summary>
  238.        
  239.         public bool ignoreTimeScale = false;
  240.        
  241.         /// <summary>
  242.         /// Delegate to trigger when the spring finishes.
  243.         /// </summary>
  244.         //public OnFinished onFinished;
  245.        
  246.         float mThreshold = 0f;
  247.        
  248.         IEnumerator SpringPositionUpdate ()
  249.         {
  250.                 while (true)
  251.                 {
  252.                         float delta = ignoreTimeScale ? UpdateRealTimeDelta() : Time.deltaTime;
  253.                         if (mThreshold == 0f) mThreshold = (targetPosition - target.localPosition).magnitude * 0.001f;
  254.                         target.localPosition = NGUIMath.SpringLerp(target.localPosition, targetPosition, strength, delta);
  255.                        
  256.                         joyStickPosX = target.transform.localPosition.x * posDivision;
  257.                         joyStickPosY = target.transform.localPosition.y * posDivision;
  258.                        
  259.                         if (mThreshold >= (targetPosition - target.localPosition).magnitude)
  260.                         {
  261.                                 target.localPosition = targetPosition; 
  262.                                 joyStickPosX = 0;
  263.                                 joyStickPosY = 0;
  264.                                 break;
  265.                         }
  266.                         yield return 0;
  267.                 }
  268.         }
  269. }

by the way, next month i was using a script like this one with NGUI and i don't remember where i fund it, but i'm pretty sure i didn't copy past any line of code to fund it....
isn't it another existing script in NGUI package ??

2
NGUI 3 Support / Re: Protection Level ??
« on: April 08, 2014, 09:19:25 AM »
it works perfectly now !

thanks ArenMook !

3
NGUI 3 Support / Re: Protection Level ??
« on: April 08, 2014, 02:11:56 AM »
should be nice to have this fix !!!

how can i have a date to tell it to my team ?

4
NGUI 3 Support / Re: Protection Level ??
« on: April 07, 2014, 03:56:50 AM »
the newest version of unityWiiU you mean ?

they still continue updating the 4.2... if it makes sence...

i have installed the older version of NGUI, it looks to works, but when i try to create an atlas, i get this:

Quote
NullReferenceException
UnityEngine.Material..ctor (UnityEngine.Shader shader) (at C:/BuildAgent/work/e32e3436d0e48bd0/Runtime/ExportGenerated/WiiUEditorExtensions/Graphics.cs:1684)
UIAtlasMaker.OnGUI () (at Assets/NGUI/Scripts/Editor/UIAtlasMaker.cs:734)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Applications/buildAgent/work/c514da0c8183631c/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

plus

if unity start looking for existing atlas, it takes eternity to see that there is not atlas in the project...

5
NGUI 3 Support / Protection Level ??
« on: April 07, 2014, 03:44:39 AM »
Hello,

i'm working with Unity WiiU version, and just installed the new update of NGUI wich show me this problem:

Quote
Assets/NGUI/Scripts/Editor/PropertyReferenceDrawer.cs(169,55): error CS0122: `UnityEditor.EditorGUIUtility.labelWidth' is inaccessible due to its protection level


6
NGUI 3 Support / Re: UI material + Particles FX
« on: March 04, 2014, 06:29:00 AM »
Thanks

7
NGUI 3 Support / Re: UIDragDropItem not under cursor
« on: March 03, 2014, 11:22:34 AM »
it's a problem of scale.

to solve it you should put the drag and drop root on an object without size modification.
try different parent to put your script.

i get the same problem for my game, because the script was attached to an object i can resize using wheel.
i put it on the parent and now it's working nice

8
NGUI 3 Support / UI material + Particles FX [Solved]
« on: March 03, 2014, 05:56:32 AM »
Hi,

i first thinking that my particles was wrong, but by turning my scene i discovered that the problem is not the particles but the material attached to the GUI.
by the way i tryed many different shaders on the UI, and no one has change the problem.

so, basicaly the UI material is an Unlit/premultiplied color
and the Fx particles in Particles/additive

if i change the UI to defaut diffuse shader, there is no change...

9
NGUI 3 Support / Re: Depth Bug
« on: March 03, 2014, 02:35:15 AM »
ok, thanks, i fund the problem using draw order tool.

the card is drawn before and so it's why it's behind the board.

10
NGUI 3 Support / Re: Depth Bug
« on: March 02, 2014, 05:28:16 AM »
any idea ?

11
NGUI 3 Support / Re: Z Depth Problem
« on: February 28, 2014, 07:30:14 PM »
ok, it seems that this problem can only be solved manuall by cliquing in the inspector panel, on something inside the UISprite script
except Depth parameter...

http://www.youtube.com/watch?v=gEi3f3taocY

12
NGUI 3 Support / Re: Z Depth Problem
« on: February 28, 2014, 06:35:04 PM »
the bug has been localized

during the game, it is possible to get the sprite in front by changing type, or anchor....

not very logic

13
NGUI 3 Support / Depth Bug [Solved]
« on: February 28, 2014, 06:10:21 AM »
Hello,

on my game i use a panel (Z = 0) using scroll view
          Below is a dragscroll view without Z information
            attached on it, i put series of squares sprites(Z = 1)
                  Some of this squares have a second sprite (Z = 2)
and when i try to parent a gameObject(Sprite) to this position(Z= 7)

the new object is behind the sexisting prites. i tryed to modify the depth of this sprite in game, but nothing is changing,
but if i put the depth of the panel down, the newest sprite appear.

http://www.youtube.com/watch?v=Xc-z67n895o

14
NGUI 3 Support / Re: drag and drop precision
« on: February 24, 2014, 08:45:47 AM »
i finally fund, i didn't put a panel with drag and drop root, since i did it it works perfectly

15
NGUI 3 Support / Re: Unable to reproduce Chat TextList
« on: February 19, 2014, 04:24:03 PM »
thx, i finally fund the problem

the text is received correctly but it need  something like teen messages before the first appear.

it's because max line was set to 1.

by the way, when the game start, there is all the test message that prints:

the text list, testing line 26[-]
[AAAAAA]This is an example paragraph for
the text list, testing line 27[-]
[FFFFFF]This is an example paragraph for
the text list, testing line 28[-]
[AAAAAA]This is an example paragraph for

where do you remove this lines ?

Pages: [1] 2