예제 #1
0
 void SubLayout()
 {
     if (go2 != null)
     {
         //GUILayout.FlexibleSpace();
         SetWidgetAttr(go2);
         SetLabel(go2);
         checkCollider = GUILayout.Toggle(checkCollider, "Scale Collider");
         //GUILayout.FlexibleSpace();
         GUILayout.BeginHorizontal();
         PositionLayout();
         GUILayout.Space(20);
         ScaleLayout();
         GUILayout.EndHorizontal();
         GUILayout.Space(10);
         vec = GUILayout.BeginScrollView(vec);
         for (int i = 0; i < go2.Length; i++)
         {
             GUILayout.BeginHorizontal();
             EditorGUILayout.TextField(NGUITools.GetHierarchy(go2[i]));
             EditorGUILayout.ObjectField(go2[i], typeof(GameObject), true, GUILayout.Width(150));
             GUILayout.EndHorizontal();
             GUILayout.Space(10);
             GUILayout.BeginHorizontal();
             EditorGUILayout.TextField("LocalPosition: " + go2[i].transform.localPosition.ToString());
             EditorGUILayout.TextField("LocalScale   : " + go2[i].transform.localScale.ToString());
             GUILayout.EndHorizontal();
         }
         GUILayout.EndScrollView();
     }
 }
예제 #2
0
 static public int GetHierarchy_s(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.GameObject a1;
         checkType(l, 1, out a1);
         var ret = NGUITools.GetHierarchy(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
예제 #3
0
    void ChangeColor(GameObject target, Color color)
    {
        if (enabled)
        {
            UIWidget widget = target.GetComponent <UIWidget>();

            if (widget != null)
            {
                widget.color = color;
            }
            else
            {
                Renderer ren = target.renderer;

                if (ren != null)
                {
                    ren.material.color = color;
                }
                else
                {
                    Light lt = target.light;

                    if (lt != null)
                    {
                        lt.color = color;
                    }
                    else
                    {
                        Debug.LogWarning(NGUITools.GetHierarchy(gameObject) + " has nothing for UIButtonColor to color", this);
                        enabled = false;
                    }
                }
            }
        }
    }
예제 #4
0
    /// <summary>
    /// Draw details about the specified monobehavior in column format.
    /// </summary>

    bool DrawObject(Object ob)
    {
        bool      retVal = false;
        Component comp   = ob as Component;

        GUILayout.BeginHorizontal();
        {
            if (comp != null && EditorUtility.IsPersistent(comp.gameObject))
            {
                GUI.contentColor = new Color(0.6f, 0.8f, 1f);
            }

            GUILayout.Label(NGUITools.GetTypeName(ob), "AS TextArea", GUILayout.Width(80f), GUILayout.Height(20f));

            if (comp != null)
            {
                GUILayout.Label(NGUITools.GetHierarchy(comp.gameObject), "AS TextArea", GUILayout.Height(20f));
            }
            else if (ob is Font)
            {
                Font fnt = ob as Font;
                GUILayout.Label(fnt.name, "AS TextArea", GUILayout.Height(20f));
            }
            GUI.contentColor = Color.white;

            retVal = GUILayout.Button("Select", "ButtonLeft", GUILayout.Width(60f), GUILayout.Height(16f));
        }
        GUILayout.EndHorizontal();
        return(retVal);
    }
예제 #5
0
    public static void CreateBitmap(PsdLayerToNGUI.Data data)
    {
        // Create a new game object for the font
        var name = data.fontTexture.name;
        var go   = new GameObject(name);

        var bitmapFont = go.AddComponent <UIFont>();

        NGUISettings.ambigiousFont = bitmapFont;
        NGUISettings.fontData      = data.fontData;
        NGUISettings.fontTexture   = data.fontTexture;
        {
            BMFontReader.Load(bitmapFont.bmFont,
                              NGUITools.GetHierarchy(bitmapFont.gameObject), NGUISettings.fontData.bytes);

            bitmapFont.spriteName = NGUISettings.fontTexture.name;
            bitmapFont.atlas      = NGUISettings.atlas;
        }

        // Update the prefab
#if UNITY_3_4
        EditorUtility.ReplacePrefab(go, NGUIFontCreator.fontPrefab);
#else
        PrefabUtility.ReplacePrefab(go, NGUIFontCreator.fontPrefab);
#endif
        GameObject.DestroyImmediate(go);
        AssetDatabase.Refresh();

        // Select the atlas
        go = AssetDatabase.LoadAssetAtPath(fontPrefabPath, typeof(GameObject)) as GameObject;

        data.fontPrefab            = go.GetComponent <UIFont>();
        data.fontPrefab.spriteName = name;
        NGUISettings.ambigiousFont = data.fontPrefab;
    }
예제 #6
0
    void DrawDetail(Entry ent, UIWidget w, int dc)
    {
        GUILayout.BeginHorizontal(GUILayout.MinHeight(20f));
        GUILayout.Space(24f);
        GUILayout.Label(w.depth.ToString(), GUILayout.Width(52f));

        var start = NGUITools.GetHierarchy(ent.panel.gameObject).Length + 1;
        var text  = NGUITools.GetHierarchy(w.gameObject).Substring(start);

        if (!w.isSelectable)
        {
            GUI.color = new Color(1f, 1f, 1f, 0.5f);
        }

        if (GUILayout.Button(text, EditorStyles.label, GUILayout.MinWidth(100f)))
        {
            Selection.activeGameObject = w.isSelectable ? w.gameObject : w.transform.parent.gameObject;
        }

        if (!w.isSelectable)
        {
            GUI.color = new Color(1f, 1f, 1f, 1f);
        }

        GUILayout.Label(dc.ToString(), GUILayout.Width(64f));
        GUILayout.Label(w.geometry != null ? (w.geometry.verts.Count / 2).ToString() : "0", GUILayout.Width(30f));
        GUILayout.Space(58f);
        GUILayout.EndHorizontal();
    }
예제 #7
0
 private void Start()
 {
     mAnim = GetComponentInChildren <Animation>();
     if (mAnim == null)
     {
         Debug.LogWarning(NGUITools.GetHierarchy(base.gameObject) + " has no Animation component");
         Object.Destroy(this);
         return;
     }
     foreach (AnimationState item in mAnim)
     {
         if (item.clip.name == "idle")
         {
             item.layer = 0;
             mIdle      = item.clip;
             mAnim.Play(mIdle.name);
         }
         else if (item.clip.name.StartsWith("idle"))
         {
             item.layer = 1;
             mBreaks.Add(item.clip);
         }
     }
     if (mBreaks.Count == 0)
     {
         Object.Destroy(this);
     }
 }
예제 #8
0
    static void CreateFont(UIFont font, int create, Material mat)
    {
        if (create == 1)
        {
            // New dynamic font
            font.atlas            = null;
            font.dynamicFont      = NGUISettings.dynamicFont;
            font.dynamicFontSize  = NGUISettings.dynamicFontSize;
            font.dynamicFontStyle = NGUISettings.dynamicFontStyle;
        }
        else
        {
            // New bitmap font
            font.dynamicFont = null;
            BMFontReader.Load(font.bmFont, NGUITools.GetHierarchy(font.gameObject), NGUISettings.fontData.bytes);

            if (create == 2)
            {
                font.atlas    = null;
                font.material = mat;
            }
            else if (create == 3)
            {
                font.spriteName = NGUISettings.fontTexture.name;
                font.atlas      = NGUISettings.atlas;
            }
        }
    }
예제 #9
0
파일: UIPanel.cs 프로젝트: happylays/tbb2
    /// <summary>
    /// Add the specified widget to the managed list.
    /// </summary>

    public void AddWidget(UIWidget w)
    {
        if (w != null)
        {
#if UNITY_EDITOR
            if (w.cachedTransform.parent != null)
            {
                UIWidget parentWidget = NGUITools.FindInParents <UIWidget>(w.cachedTransform.parent.gameObject);

                if (parentWidget != null)
                {
                    w.cachedTransform.parent = parentWidget.cachedTransform.parent;
                    Debug.LogError("You should never nest widgets! Parent them to a common game object instead. Forcefully changing the parent.", w);

                    // If the error above gets triggered, it means that you parented one widget to another.
                    // If left unchecked, this may lead to odd behavior in the UI. Consider restructuring your UI.
                    // For example, if you were trying to do this:

                    // Widget #1
                    //  |
                    //  +- Widget #2

                    // You can do this instead, fixing the problem:

                    // GameObject (scale 1, 1, 1)
                    //  |
                    //  +- Widget #1
                    //  |
                    //  +- Widget #2
                }
            }
#endif

            UINode node = AddTransform(w.cachedTransform);

            if (node != null)
            {
                node.widget   = w;
                w.visibleFlag = 1;

                if (!mWidgets.Contains(w))
                {
                    mWidgets.Add(w);

                    if (!mChanged.Contains(w.material))
                    {
                        mChanged.Add(w.material);
                        mChangedLastFrame = true;
                    }
                    mDepthChanged = true;
                    mWidgetsAdded = true;
                }
            }
            else
            {
                Debug.LogError("Unable to find an appropriate root for " + NGUITools.GetHierarchy(w.gameObject) +
                               "\nPlease make sure that there is at least one game object above this widget!", w.gameObject);
            }
        }
    }
예제 #10
0
    protected void Init()
    {
        if (this.tweenTarget == null)
        {
            this.tweenTarget = base.gameObject;
        }
        UIWidget component = this.tweenTarget.GetComponent <UIWidget>();

        if (component != null)
        {
            this.mColor = component.color;
        }
        else
        {
            Renderer renderer = this.tweenTarget.renderer;
            if (renderer != null)
            {
                this.mColor = renderer.material.color;
            }
            else
            {
                Light light = this.tweenTarget.light;
                if (light != null)
                {
                    this.mColor = light.color;
                }
                else
                {
                    Debug.LogWarning(NGUITools.GetHierarchy(base.gameObject) + " has nothing for UIButtonColor to color", this);
                    base.enabled = false;
                }
            }
        }
        this.OnEnable();
    }
예제 #11
0
    /// <summary>
    /// Find all idle animations.
    /// </summary>

    void Start()
    {
        mAnim = GetComponentInChildren <Animation>();

        if (mAnim == null)
        {
            Debug.LogWarning(NGUITools.GetHierarchy(gameObject) + " has no Animation component");
            Destroy(this);
        }
        else
        {
            foreach (AnimationState state in mAnim)
            {
                if (state.clip.name == "idle")
                {
                    state.layer = 0;
                    mIdle       = state.clip;
                    mAnim.Play(mIdle.name);
                }
                else if (state.clip.name.StartsWith("idle"))
                {
                    state.layer = 1;
                    mBreaks.Add(state.clip);
                }
            }

            // No idle breaks found -- this script is unnecessary
            if (mBreaks.Count == 0)
            {
                Destroy(this);
            }
        }
    }
예제 #12
0
 void OnGUI()
 {
     if (debug && hoveredObject != null)
     {
         GUILayout.Label("Last Hit: " + NGUITools.GetHierarchy(hoveredObject).Replace("\"", ""));
     }
 }
예제 #13
0
 private void OnGUI()
 {
     if (GUILayout.Button("clear", new GUILayoutOption[]
     {
         GUILayout.Height(30f)
     }))
     {
         NGUIDebug.mLines.Clear();
     }
     if (NGUIDebug.mLines.Count == 0)
     {
         if (NGUIDebug.mRayDebug && UICamera.hoveredObject != null)
         {
             GUILayout.Label("Last Hit: " + NGUITools.GetHierarchy(UICamera.hoveredObject).Replace("\"", string.Empty), new GUILayoutOption[0]);
         }
     }
     else
     {
         int i     = 0;
         int count = NGUIDebug.mLines.Count;
         while (i < count)
         {
             GUIStyle gUIStyle = new GUIStyle();
             gUIStyle.fontSize         = 26;
             gUIStyle.normal.textColor = Color.red;
             GUILayout.Label(NGUIDebug.mLines[i], gUIStyle, new GUILayoutOption[0]);
             i++;
         }
     }
 }
예제 #14
0
 void OnGUI()
 {
     if (debug && lastHit.collider != null)
     {
         GUILayout.Label("Last Hit: " + NGUITools.GetHierarchy(lastHit.collider.gameObject).Replace("\"", ""));
     }
 }
예제 #15
0
    static void CreateFont(UIFont font, int create, Material mat)
    {
        if (create == 1)
        {
            // New dynamic font
            //font.atlas = null;
            //font.dynamicFont = NGUISettings.trueTypeFont;
            //font.dynamicFontStyle = NGUISettings.fontStyle;
            Debug.LogError("Creating UIFont for dynamic fonts is no longer needed. Reference the font directly on your label.");
        }
        else
        {
            // New bitmap font
            font.dynamicFont = null;
            BMFontReader.Load(font.bmFont, NGUITools.GetHierarchy(font.gameObject), NGUISettings.fontData.bytes);

            if (create == 2)
            {
                font.atlas    = null;
                font.material = mat;
            }
            else if (create == 3)
            {
                font.spriteName = NGUISettings.fontTexture.name;
                font.atlas      = NGUISettings.atlas;
            }
        }
    }
예제 #16
0
 public void AddWidget(UIWidget w)
 {
     if (w != null)
     {
         UINode node = this.AddTransform(w.cachedTransform);
         if (node != null)
         {
             node.widget = w;
             if (!this.mWidgets.Contains(w))
             {
                 this.mWidgets.Add(w);
                 if (!this.mChanged.Contains(w.material))
                 {
                     this.mChanged.Add(w.material);
                     this.mChangedLastFrame = true;
                 }
                 this.mDepthChanged = true;
             }
         }
         else
         {
             Debug.LogError("Unable to find an appropriate UIRoot for " + NGUITools.GetHierarchy(w.gameObject) + "\nPlease make sure that there is at least one game object above this widget!", w.gameObject);
         }
     }
 }
예제 #17
0
    protected void Init()
    {
        this.mInitDone = true;
        if (this.tweenTarget == null)
        {
            this.tweenTarget = base.gameObject;
        }
        UIWidget component = this.tweenTarget.GetComponent <UIWidget>();

        if (component == null)
        {
            Renderer renderer = this.tweenTarget.renderer;
            if (renderer == null)
            {
                Light light = this.tweenTarget.light;
                if (light == null)
                {
                    Debug.LogWarning(string.Concat(NGUITools.GetHierarchy(base.gameObject), " has nothing for UIButtonColor to color"), this);
                    base.enabled = false;
                }
                else
                {
                    this.mColor = light.color;
                }
            }
            else
            {
                this.mColor = renderer.material.color;
            }
        }
        else
        {
            this.mColor = component.color;
        }
    }
 // Token: 0x06000133 RID: 307 RVA: 0x0001309C File Offset: 0x0001129C
 private void Start()
 {
     this.mAnim = base.GetComponentInChildren <Animation>();
     if (this.mAnim == null)
     {
         Debug.LogWarning(NGUITools.GetHierarchy(base.gameObject) + " has no Animation component");
         UnityEngine.Object.Destroy(this);
         return;
     }
     foreach (object obj in this.mAnim)
     {
         AnimationState animationState = (AnimationState)obj;
         if (animationState.clip.name == "idle")
         {
             animationState.layer = 0;
             this.mIdle           = animationState.clip;
             this.mAnim.Play(this.mIdle.name);
         }
         else if (animationState.clip.name.StartsWith("idle"))
         {
             animationState.layer = 1;
             this.mBreaks.Add(animationState.clip);
         }
     }
     if (this.mBreaks.Count == 0)
     {
         UnityEngine.Object.Destroy(this);
     }
 }
예제 #19
0
    public static T Begin <T>(GameObject go, float duration, float delay = 0f) where T : UITweener
    {
        T t = go.GetComponent <T>();

        if (t != null && t.tweenGroup != 0)
        {
            t = (T)((object)null);
            T[] components = go.GetComponents <T>();
            int i          = 0;
            int num        = components.Length;
            while (i < num)
            {
                t = components[i];
                if (t != null && t.tweenGroup == 0)
                {
                    break;
                }
                t = (T)((object)null);
                i++;
            }
        }
        if (t == null)
        {
            t = go.AddComponent <T>();
            if (t == null)
            {
                Debug.LogError(string.Concat(new object[]
                {
                    "Unable to add ",
                    typeof(T),
                    " to ",
                    NGUITools.GetHierarchy(go)
                }), go);
                return((T)((object)null));
            }
        }
        t.mStarted        = false;
        t.mFactor         = 0f;
        t.duration        = duration;
        t.mDuration       = duration;
        t.delay           = delay;
        t.mAmountPerDelta = ((duration <= 0f) ? 1000f : Mathf.Abs(1f / duration));
        t.style           = UITweener.Style.Once;
        t.animationCurve  = new AnimationCurve(new Keyframe[]
        {
            new Keyframe(0f, 0f, 0f, 1f),
            new Keyframe(1f, 1f, 1f, 0f)
        });
        t.eventReceiver    = null;
        t.callWhenFinished = null;
        t.onFinished.Clear();
        if (t.mTemp != null)
        {
            t.mTemp.Clear();
        }
        t.enabled = true;
        return(t);
    }
예제 #20
0
    private static int GetHierarchy(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        GameObject obj       = (GameObject)LuaScriptMgr.GetUnityObject(L, 1, typeof(GameObject));
        string     hierarchy = NGUITools.GetHierarchy(obj);

        LuaScriptMgr.Push(L, hierarchy);
        return(1);
    }
예제 #21
0
    static int GetHierarchy(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        GameObject arg0 = (GameObject)LuaScriptMgr.GetUnityObject(L, 1, typeof(GameObject));
        string     o    = NGUITools.GetHierarchy(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
예제 #22
0
 private void Awake()
 {
     this.mCam   = base.GetComponent <Camera>();
     this.mTrans = base.transform;
     if (this.rootForBounds == null)
     {
         Debug.LogError(NGUITools.GetHierarchy(base.gameObject) + " needs the 'Root For Bounds' parameter to be set", this);
         base.enabled = false;
     }
 }
예제 #23
0
 private void Awake()
 {
     this.mCam   = base.camera;
     this.mTrans = base.transform;
     if (this.rootForBounds == null)
     {
         Debug.LogError(string.Concat(NGUITools.GetHierarchy(base.gameObject), " needs the 'Root For Bounds' parameter to be set"), this);
         base.enabled = false;
     }
 }
예제 #24
0
 private void Awake()
 {
     mCam   = camera;
     mTrans = transform;
     if (rootForBounds == null)
     {
         Debug.LogError(NGUITools.GetHierarchy(gameObject) + " needs the 'Root For Bounds' parameter to be set", this);
         enabled = false;
     }
 }
예제 #25
0
    /// <summary>
    /// Starts the tweening operation.
    /// </summary>

    static public T Begin <T> (GameObject go, float duration, float delay = 0f) where T : UITweener
    {
        T comp = go.GetComponent <T>();

#if UNITY_FLASH
        if ((object)comp == null)
        {
            comp = (T)go.AddComponent <T>();
        }
#else
        // Find the tween with an unset group ID (group ID of 0).
        if (comp != null && comp.tweenGroup != 0)
        {
            comp = null;
            T[] comps = go.GetComponents <T>();
            for (int i = 0, imax = comps.Length; i < imax; ++i)
            {
                comp = comps[i];
                if (comp != null && comp.tweenGroup == 0)
                {
                    break;
                }
                comp = null;
            }
        }

        if (comp == null)
        {
            comp = go.AddComponent <T>();

            if (comp == null)
            {
                Debug.LogError("Unable to add " + typeof(T) + " to " + NGUITools.GetHierarchy(go), go);
                return(null);
            }
        }
#endif
        comp.mStarted         = false;
        comp.mFactor          = 0f;
        comp.duration         = duration;
        comp.mDuration        = duration;
        comp.delay            = delay;
        comp.mAmountPerDelta  = duration > 0f ? Mathf.Abs(1f / duration) : 1000f;
        comp.style            = Style.Once;
        comp.animationCurve   = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
        comp.eventReceiver    = null;
        comp.callWhenFinished = null;
        comp.onFinished.Clear();
        if (comp.mTemp != null)
        {
            comp.mTemp.Clear();
        }
        comp.enabled = true;
        return(comp);
    }
예제 #26
0
 private void Start()
 {
     this.mCam   = base.GetComponent <Camera>();
     this.mTrans = base.transform;
     this.mRoot  = NGUITools.FindInParents <UIRoot>(base.gameObject);
     if (this.rootForBounds == (UnityEngine.Object)null)
     {
         global::Debug.LogError(NGUITools.GetHierarchy(base.gameObject) + " needs the 'Root For Bounds' parameter to be set", this);
         base.enabled = false;
     }
 }
예제 #27
0
 private void Start()
 {
     mCam   = GetComponent <Camera>();
     mTrans = base.transform;
     mRoot  = NGUITools.FindInParents <UIRoot>(base.gameObject);
     if (rootForBounds == null)
     {
         Debug.LogError(NGUITools.GetHierarchy(base.gameObject) + " needs the 'Root For Bounds' parameter to be set", this);
         base.enabled = false;
     }
 }
예제 #28
0
 public override void Init()
 {
     base.Init();
     this.m_uiSprite = base.GetComponent <UISprite>();
     if (null == this.m_uiSprite)
     {
         string hierarchy = NGUITools.GetHierarchy(base.gameObject);
         Debug.LogError("null == m_uiSprite:" + hierarchy);
     }
     this.m_uiSpriteAnimation = base.GetComponent <UISpriteAnimation>();
 }
예제 #29
0
    /// <summary>
    /// Cache the common components.
    /// </summary>

    void Awake()
    {
        mCam   = GetComponent <Camera>();
        mTrans = transform;

        if (rootForBounds == null)
        {
            LogSystem.LogWarning(NGUITools.GetHierarchy(gameObject), " needs the 'Root For Bounds' parameter to be set", this);
            enabled = false;
        }
    }
 private void Start()
 {
     this.mCam   = base.GetComponent <Camera>();
     this.mTrans = base.get_transform();
     this.mRoot  = NGUITools.FindInParents <UIRoot>(base.get_gameObject());
     if (this.rootForBounds == null)
     {
         Debug.LogError(NGUITools.GetHierarchy(base.get_gameObject()) + " needs the 'Root For Bounds' parameter to be set", this);
         base.set_enabled(false);
     }
 }