MarkAsChanged() public method

Tell the panel responsible for the widget that something has changed and the buffers need to be rebuilt.
public MarkAsChanged ( ) : void
return void
 public void MarkWidgetAsChanged_NGUI(bool MarkVertices = true, bool MarkMaterial = false)
 {
     if (mNGUI_Widget)
     {
         if (MarkMaterial)
         {
             mNGUI_Widget.RemoveFromPanel();
         }
         mNGUI_Widget.MarkAsChanged();
     }
 }
Exemplo n.º 2
0
 static public int MarkAsChanged(IntPtr l)
 {
     try {
         UIWidget self = (UIWidget)checkSelf(l);
         self.MarkAsChanged();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 3
0
	static int MarkAsChanged(IntPtr L)
	{
		try
		{
			ToLua.CheckArgsCount(L, 1);
			UIWidget obj = (UIWidget)ToLua.CheckObject<UIWidget>(L, 1);
			obj.MarkAsChanged();
			return 0;
		}
		catch (Exception e)
		{
			return LuaDLL.toluaL_exception(L, e);
		}
	}
Exemplo n.º 4
0
        /// <summary>
        /// 刷新对象
        /// </summary>
        public static void RefreshTrans(Transform trans)
        {
            int      childNum   = trans.childCount;
            UIWidget selfWidget = trans.GetComponent <UIWidget>();

            if (selfWidget != null)
            {
                selfWidget.ParentHasChanged();
                selfWidget.MarkAsChanged();
            }
            for (int i = 0; i < childNum; i++)
            {
                Transform childTrans = trans.GetChild(i);
                RefreshTrans(childTrans);
            }
        }
Exemplo n.º 5
0
    public void refreshVisible(GameObject go)
    {
        if (go == null)
        {
            return;
        }

        UIPanel panel = go.GetComponent <UIPanel>();

        if (panel != null)
        {
            NGUITools.MarkParentAsChanged(go);
            go.BroadcastMessage("CreatePanel", SendMessageOptions.DontRequireReceiver);
        }

        // gather all of the widgets in this panel
        {
            UIWidget widget = go.GetComponent <UIWidget>();
            if (widget != null)
            {
                widget.MakePixelPerfect();
                widget.MarkAsChanged();
            }
        }

        UIWidget [] widgets = go.GetComponentsInChildren <UIWidget>();
        if (widgets != null)
        {
            foreach (UIWidget w in widgets)
            {
                // fix the transform scale so this object appears "pixel perfect"
                w.MakePixelPerfect();
                w.MarkAsChanged();
            }
        }

        if (panel != null)
        {
            panel.Refresh();
            go.BroadcastMessage("CreatePanel", SendMessageOptions.DontRequireReceiver);
            NGUITools.MarkParentAsChanged(go);
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// Draw the inspector widget.
    /// </summary>
    public override void OnInspectorGUI()
    {
        EditorGUIUtility.LookLikeControls(80f);
        mWidget = target as UIWidget;

        #if UNITY_3_4
        PrefabType type = EditorUtility.GetPrefabType(mWidget.gameObject);
        #else
        PrefabType type = PrefabUtility.GetPrefabType(mWidget.gameObject);
        #endif

        if (type == PrefabType.Prefab)
        {
            GUILayout.Label("Drag this widget into the scene to modify it.");
        }
        else
        {
            if (!mInitialized)
            {
                mInitialized = true;
                OnInit();
            }

            NGUIEditorTools.DrawSeparator();

            // Check the hierarchy to ensure that this widget is not parented to another widget
            if (mHierarchyCheck) CheckHierarchy();

            // This flag gets set to 'true' if RegisterUndo() gets called
            mRegisteredUndo = false;

            // Check to see if we can draw the widget's default properties to begin with
            if (OnDrawProperties())
            {
                // Draw all common properties next
                DrawCommonProperties();
            }

            // Update the widget's properties if something has changed
            if (mRegisteredUndo) mWidget.MarkAsChanged();
        }
    }
Exemplo n.º 7
0
    /// <summary>
    /// Update the visible slider.
    /// </summary>

    void Set(float input, bool force)
    {
        if (!mInitDone)
        {
            Init();
        }

        // Clamp the input
        float val = Mathf.Clamp01(input);

        if (val < 0.001f)
        {
            val = 0f;
        }

        float prevStep = sliderValue;

        // Save the raw value
        rawValue = val;

        // Take steps into account
        float stepValue = sliderValue;

        // If the stepped value doesn't match the last one, it's time to update
        if (force || prevStep != stepValue)
        {
            Vector3 scale = mSize;

#if UNITY_EDITOR
            if (Application.isPlaying)
            {
                if (direction == Direction.Horizontal)
                {
                    scale.x *= stepValue;
                }
                else
                {
                    scale.y *= stepValue;
                }
            }
#else
            if (direction == Direction.Horizontal)
            {
                scale.x *= stepValue;
            }
            else
            {
                scale.y *= stepValue;
            }
#endif

#if UNITY_EDITOR
            if (Application.isPlaying)
#endif
            {
                if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
                {
                    mFGFilled.fillAmount = stepValue;
                }
                else if (foreground != null)
                {
                    mFGTrans.localScale = scale;

                    if (mFGWidget != null)
                    {
                        if (stepValue > 0.001f)
                        {
                            mFGWidget.enabled = true;
                            mFGWidget.MarkAsChanged();
                        }
                        else
                        {
                            mFGWidget.enabled = false;
                        }
                    }
                }
            }

            if (thumb != null)
            {
                Vector3 pos = thumb.localPosition;

                if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
                {
                    if (mFGFilled.fillDirection == UISprite.FillDirection.Horizontal)
                    {
                        pos.x = mFGFilled.invert ? mSize.x - scale.x : scale.x;
                    }
                    else if (mFGFilled.fillDirection == UISprite.FillDirection.Vertical)
                    {
                        pos.y = mFGFilled.invert ? mSize.y - scale.y : scale.y;
                    }
                    else
                    {
                        Debug.LogWarning("Slider thumb is only supported with Horizontal or Vertical fill direction", this);
                    }
                }
                else if (direction == Direction.Horizontal)
                {
                    pos.x = scale.x;
                }
                else
                {
                    pos.y = scale.y;
                }
                thumb.localPosition = pos;
            }

            current = this;

            if (eventReceiver != null && !string.IsNullOrEmpty(functionName) && Application.isPlaying)
            {
                eventReceiver.SendMessage(functionName, stepValue, SendMessageOptions.DontRequireReceiver);
            }
            if (onValueChange != null)
            {
                onValueChange(stepValue);
            }
            current = null;
        }
    }
Exemplo n.º 8
0
    private void Set(float input, bool force)
    {
        if (!mInitDone)
        {
            Init();
        }
        float num = Mathf.Clamp01(input);

        if (num < 0.001f)
        {
            num = 0f;
        }
        float sliderValue = this.sliderValue;

        rawValue = num;
        float sliderValue2 = this.sliderValue;

        if (!force && sliderValue == sliderValue2)
        {
            return;
        }
        Vector3 localScale = mSize;

        if (direction == Direction.Horizontal)
        {
            localScale.x *= sliderValue2;
        }
        else
        {
            localScale.y *= sliderValue2;
        }
        if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
        {
            mFGFilled.fillAmount = sliderValue2;
        }
        else if (foreground != null)
        {
            mFGTrans.localScale = localScale;
            if (mFGWidget != null)
            {
                if (sliderValue2 > 0.001f)
                {
                    mFGWidget.enabled = true;
                    mFGWidget.MarkAsChanged();
                }
                else
                {
                    mFGWidget.enabled = false;
                }
            }
        }
        if (thumb != null)
        {
            Vector3 localPosition = thumb.localPosition;
            if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
            {
                if (mFGFilled.fillDirection == UISprite.FillDirection.Horizontal)
                {
                    localPosition.x = ((!mFGFilled.invert) ? localScale.x : (mSize.x - localScale.x));
                }
                else if (mFGFilled.fillDirection == UISprite.FillDirection.Vertical)
                {
                    localPosition.y = ((!mFGFilled.invert) ? localScale.y : (mSize.y - localScale.y));
                }
                else
                {
                    Debug.LogWarning("Slider thumb is only supported with Horizontal or Vertical fill direction", this);
                }
            }
            else if (direction == Direction.Horizontal)
            {
                localPosition.x = localScale.x;
            }
            else
            {
                localPosition.y = localScale.y;
            }
            thumb.localPosition = localPosition;
        }
        current = this;
        if (eventReceiver != null && !string.IsNullOrEmpty(functionName) && Application.isPlaying)
        {
            eventReceiver.SendMessage(functionName, sliderValue2, SendMessageOptions.DontRequireReceiver);
        }
        if (onValueChange != null)
        {
            onValueChange(sliderValue2);
        }
        current = null;
    }
Exemplo n.º 9
0
    /// <summary>
    /// Update the visible slider.
    /// </summary>

    void Set(float input, bool force)
    {
        if (!mInitDone)
        {
            Init();
        }

        // Clamp the input
        float val = Mathf.Clamp01(input);

        if (val < 0.001f)
        {
            val = 0f;
        }

        // Save the raw value
        rawValue = val;

        // Take steps into consideration
        if (numberOfSteps > 1)
        {
            val = Mathf.Round(val * (numberOfSteps - 1)) / (numberOfSteps - 1);
        }

        // If the stepped value doesn't match the last one, it's time to update
        if (force || mStepValue != val)
        {
            mStepValue = val;
            Vector3 scale = fullSize;

            if (direction == Direction.Horizontal)
            {
                scale.x *= mStepValue;
            }
            else
            {
                scale.y *= mStepValue;
            }

            if (mFGFilled != null)
            {
                mFGFilled.fillAmount = mStepValue;
            }
            else if (foreground != null)
            {
                mFGTrans.localScale = scale;

                if (mFGWidget != null)
                {
                    if (val > 0.001f)
                    {
                        mFGWidget.enabled = true;
                        mFGWidget.MarkAsChanged();
                    }
                    else
                    {
                        mFGWidget.enabled = false;
                    }
                }
            }

            if (thumb != null)
            {
                Vector3 pos = thumb.localPosition;

                if (mFGFilled != null)
                {
                    if (mFGFilled.fillDirection == UIFilledSprite.FillDirection.Horizontal)
                    {
                        pos.x = mFGFilled.invert ? fullSize.x - scale.x : scale.x;
                    }
                    else if (mFGFilled.fillDirection == UIFilledSprite.FillDirection.Vertical)
                    {
                        pos.y = mFGFilled.invert ? fullSize.y - scale.y : scale.y;
                    }
                }
                else if (direction == Direction.Horizontal)
                {
                    pos.x = scale.x;
                }
                else
                {
                    pos.y = scale.y;
                }
                thumb.localPosition = pos;
            }

            if (eventReceiver != null && !string.IsNullOrEmpty(functionName) && Application.isPlaying)
            {
                current = this;
                eventReceiver.SendMessage(functionName, mStepValue, SendMessageOptions.DontRequireReceiver);
                current = null;
            }
        }
    }
Exemplo n.º 10
0
    /// <summary>
    /// All widgets have depth, color and make pixel-perfect options
    /// </summary>

    protected void DrawCommonProperties()
    {
#if UNITY_3_4
        PrefabType type = EditorUtility.GetPrefabType(mWidget.gameObject);
#else
        PrefabType type = PrefabUtility.GetPrefabType(mWidget.gameObject);
#endif

        NGUIEditorTools.DrawSeparator();

        // Depth navigation
        if (type != PrefabType.Prefab)
        {
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Depth");

                int depth = mWidget.depth;
                if (GUILayout.Button("Back"))
                {
                    --depth;
                }
                depth = EditorGUILayout.IntField(depth, GUILayout.Width(40f));
                if (GUILayout.Button("Forward"))
                {
                    ++depth;
                }

                if (mWidget.depth != depth)
                {
                    NGUIEditorTools.RegisterUndo("Depth Change", mWidget);
                    mWidget.depth = depth;
                }
            }
            GUILayout.EndHorizontal();
        }

        Color color = EditorGUILayout.ColorField("Color Tint", mWidget.color);

        if (mWidget.color != color)
        {
            NGUIEditorTools.RegisterUndo("Color Change", mWidget);
            mWidget.color = color;
        }
        // Depth navigation
        if (type != PrefabType.Prefab)
        {
            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Normalize");
                if (GUILayout.Button("Normalize from old version"))
                {
                    mWidget.FixOldVersion();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("Correction");

                if (GUILayout.Button("Make Pixel-Perfect"))
                {
                    NGUIEditorTools.RegisterUndo("Make Pixel-Perfect", mWidget.transform);
                    mWidget.MakePixelPerfect();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            {
                EditorGUILayout.PrefixLabel("MarkChanged");

                if (GUILayout.Button("Mark As Changed"))
                {
                    if (mWidget is UISprite)
                    {
                        (mWidget as UISprite).UpdateUVs();
                    }
                    mWidget.MarkAsChanged();
                }
            }
            GUILayout.EndHorizontal();
        }

        UIWidget.Pivot pivot = (UIWidget.Pivot)EditorGUILayout.EnumPopup("Pivot", mWidget.pivot);

        if (mWidget.pivot != pivot)
        {
            NGUIEditorTools.RegisterUndo("Pivot Change", mWidget);
            mWidget.pivot = pivot;
        }

        DrawDimensions();

        if (mAllowPreview && mWidget.mainTexture != null)
        {
            GUILayout.BeginHorizontal();
            {
                UISettings.texturePreview = EditorGUILayout.Toggle("Preview", UISettings.texturePreview, GUILayout.Width(100f));

                /*if (UISettings.texturePreview)
                 * {
                 *      if (mUseShader != EditorGUILayout.Toggle("Use Shader", mUseShader))
                 *      {
                 *              mUseShader = !mUseShader;
                 *
                 *              if (mUseShader)
                 *              {
                 *                      // TODO: Remove this when Unity fixes the bug with DrawPreviewTexture not being affected by BeginGroup
                 *                      Debug.LogWarning("There is a bug in Unity that prevents the texture from getting clipped properly.\n" +
                 *                              "Until it's fixed by Unity, your texture may spill onto the rest of the Unity's GUI while using this mode.");
                 *              }
                 *      }
                 * }*/
            }
            GUILayout.EndHorizontal();



            // Draw the texture last
            if (UISettings.texturePreview)
            {
                OnDrawTexture();
            }
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// Update the visible slider.
    /// </summary>

    void Set(float input)
    {
        // Clamp the input
        float val = Mathf.Clamp01(input);

        if (val < 0.001f)
        {
            val = 0f;
        }

        // Save the raw value
        rawValue = val;

        // Take steps into consideration
        if (numberOfSteps > 1)
        {
            val = Mathf.Round(val * (numberOfSteps - 1)) / (numberOfSteps - 1);
        }
        ;

        // If the stepped value doesn't match the last one, it's time to update
        if (mStepValue != val)
        {
            mStepValue = val;
            Vector3 scale = fullSize;

            if (direction == Direction.Horizontal)
            {
                scale.x *= mStepValue;
            }
            else
            {
                scale.y *= mStepValue;
            }

            if (mSprite != null)
            {
                mSprite.fillAmount = mStepValue;
            }
            else if (mForeTrans != null)
            {
                mForeTrans.localScale = scale;
                if (mWidget != null)
                {
                    mWidget.MarkAsChanged();
                }
            }

            if (thumb != null)
            {
                Vector3 pos = thumb.localPosition;

                if (mSprite != null)
                {
                    switch (mSprite.fillDirection)
                    {
                    case UIFilledSprite.FillDirection.TowardRight:          pos.x = scale.x; break;

                    case UIFilledSprite.FillDirection.TowardTop:            pos.y = scale.y; break;

                    case UIFilledSprite.FillDirection.TowardLeft:           pos.x = fullSize.x - scale.x; break;

                    case UIFilledSprite.FillDirection.TowardBottom:         pos.y = fullSize.y - scale.y; break;
                    }
                }
                else if (direction == Direction.Horizontal)
                {
                    pos.x = scale.x;
                }
                else
                {
                    pos.y = scale.y;
                }
                thumb.localPosition = pos;
            }

            if (eventReceiver != null && !string.IsNullOrEmpty(functionName) && Application.isPlaying)
            {
                current = this;
                eventReceiver.SendMessage(functionName, mStepValue, SendMessageOptions.DontRequireReceiver);
                current = null;
            }
        }
    }
Exemplo n.º 12
0
    private void Set(float input, bool force)
    {
        if (!mInitDone)
        {
            Init();
        }

        var num = Mathf.Clamp01(input);

        if (num < 0.001f)
        {
            num = 0f;
        }

        var sliderValue = this.sliderValue;

        rawValue = num;
        var num3 = this.sliderValue;

        if (force || sliderValue != num3)
        {
            Vector3 mSize = this.mSize;
            if (direction == Direction.Horizontal)
            {
                mSize.x *= num3;
            }
            else
            {
                mSize.y *= num3;
            }

            if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
            {
                mFGFilled.fillAmount = num3;
            }
            else if (foreground != null)
            {
                mFGTrans.localScale = mSize;
                if (mFGWidget != null)
                {
                    if (num3 > 0.001f)
                    {
                        mFGWidget.enabled = true;
                        mFGWidget.MarkAsChanged();
                    }
                    else
                    {
                        mFGWidget.enabled = false;
                    }
                }
            }

            if (thumb != null)
            {
                var localPosition = thumb.localPosition;
                if (mFGFilled != null && mFGFilled.type == UISprite.Type.Filled)
                {
                    if (mFGFilled.fillDirection == UISprite.FillDirection.Horizontal)
                    {
                        localPosition.x = !mFGFilled.invert ? mSize.x : this.mSize.x - mSize.x;
                    }
                    else if (mFGFilled.fillDirection == UISprite.FillDirection.Vertical)
                    {
                        localPosition.y = !mFGFilled.invert ? mSize.y : this.mSize.y - mSize.y;
                    }
                    else
                    {
                        Debug.LogWarning("Slider thumb is only supported with Horizontal or Vertical fill direction", this);
                    }
                }
                else if (direction == Direction.Horizontal)
                {
                    localPosition.x = mSize.x;
                }
                else
                {
                    localPosition.y = mSize.y;
                }

                thumb.localPosition = localPosition;
            }

            current = this;
            if (eventReceiver != null && !string.IsNullOrEmpty(functionName) && Application.isPlaying)
            {
                eventReceiver.SendMessage(functionName, num3, SendMessageOptions.DontRequireReceiver);
            }

            onValueChange?.Invoke(num3);
            current = null;
        }
    }