public override void Copy(SpriteRoot s)
    {
        base.Copy(s);
        if (!(s is AutoSpriteBase))
        {
            return;
        }
        AutoSpriteBase autoSpriteBase = (AutoSpriteBase)s;

        if (autoSpriteBase.spriteMesh != null)
        {
            if (autoSpriteBase.animations.Length > 0)
            {
                this.animations = new UVAnimation[autoSpriteBase.animations.Length];
                for (int i = 0; i < this.animations.Length; i++)
                {
                    this.animations[i] = autoSpriteBase.animations[i].Clone();
                }
            }
        }
        else if (this.States != null)
        {
            this.animations = new UVAnimation[autoSpriteBase.States.Length];
            for (int j = 0; j < autoSpriteBase.States.Length; j++)
            {
                this.animations[j] = new UVAnimation();
                this.animations[j].SetAnim(autoSpriteBase.States[j], j);
            }
        }
    }
Exemplo n.º 2
0
    public override void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        base.Copy(s, flags);
        if (!(s is UITextField))
        {
            return;
        }
        UITextField uITextField = (UITextField)s;

        if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
        {
            this.maxLength = uITextField.maxLength;
            if (TsPlatform.IsMobile)
            {
                this.type        = uITextField.type;
                this.autoCorrect = uITextField.autoCorrect;
                this.secure      = uITextField.secure;
                this.alert       = uITextField.alert;
            }
            this.typingSoundEffect = uITextField.typingSoundEffect;
            this.fieldFullSound    = uITextField.fieldFullSound;
        }
        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            this.caret.Copy(uITextField.caret);
        }
        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
        {
            this.insert = uITextField.insert;
            this.Text   = uITextField.Text;
        }
    }
Exemplo n.º 3
0
    // Mirrors the specified sprite's settings
    public override void Mirror(SpriteRoot s)
    {
        base.Mirror(s);

        lowerLeftPixel  = ((Sprite)s).lowerLeftPixel;
        pixelDimensions = ((Sprite)s).pixelDimensions;
    }
Exemplo n.º 4
0
    public override void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        base.Copy(s, flags);

        if (!(s is UIScrollKnob))
        {
            return;
        }

        UIScrollKnob b = (UIScrollKnob)s;


        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
        {
            origPos   = b.origPos;
            ctrlPlane = b.ctrlPlane;
            slider    = b.slider;
        }

        if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
        {
            maxScrollPos       = b.maxScrollPos;
            colliderSizeFactor = b.colliderSizeFactor;
        }
    }
 public void Start(SpriteRoot sprt, EZAnimation.ANIM_MODE mode, Color begin, Color dest, EZAnimation.Interpolator interp, float dur, float delay, EZAnimation.CompletionDelegate startDel, EZAnimation.CompletionDelegate del)
 {
     this.sprite = sprt;
     this.start  = begin;
     this.m_mode = mode;
     if (mode == EZAnimation.ANIM_MODE.By)
     {
         this.delta = dest;
     }
     else
     {
         this.delta = new Color(dest.r - this.start.r, dest.g - this.start.g, dest.b - this.start.b, dest.a - this.start.a);
     }
     this.end               = this.start + this.delta;
     this.interpolator      = interp;
     this.duration          = dur;
     this.m_wait            = delay;
     this.completedDelegate = del;
     this.startDelegate     = startDel;
     base.StartCommon();
     if (mode == EZAnimation.ANIM_MODE.FromTo && delay == 0f)
     {
         this.sprite.SetColor(this.start);
     }
     EZAnimator.instance.AddAnimation(this);
 }
    public static FadeSprite Do(SpriteRoot sprt, EZAnimation.ANIM_MODE mode, Color dest, EZAnimation.Interpolator interp, float dur, float delay, EZAnimation.CompletionDelegate startDel, EZAnimation.CompletionDelegate del)
    {
        FadeSprite fadeSprite = (FadeSprite)EZAnimator.instance.GetAnimation(EZAnimation.ANIM_TYPE.FadeSprite);

        fadeSprite.Start(sprt, mode, dest, interp, dur, delay, startDel, del);
        return(fadeSprite);
    }
Exemplo n.º 7
0
    // Returns true if any of the settings do not match:
    public override bool DidChange(SpriteRoot s)
    {
        UITextField tf = (UITextField)s;

        if (margins.x != tf.margins.x ||
            margins.y != tf.margins.y ||
            width != tf.width ||
            height != tf.height)
        {
            tf.SetMargins(tf.margins);
            tf.CalcClippingRect();
            margins = tf.margins;
            // Keep it to ourselves since we handled it
            //return true;
        }
        if (multiline != tf.multiline)
        {
            if (tf.spriteText != null)
            {
                tf.spriteText.multiline = tf.multiline;
            }
            return(true);
        }

        return(base.DidChange(s));
    }
Exemplo n.º 8
0
 public void AlphaAni(float startA, float destA, float time)
 {
     SpriteRoot[] componentsInChildren = base.transform.GetComponentsInChildren <SpriteRoot>(true);
     if (componentsInChildren != null)
     {
         SpriteRoot[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             SpriteRoot spriteRoot = array[i];
             if (null != spriteRoot)
             {
                 FadeSprite.Do(spriteRoot, EZAnimation.ANIM_MODE.FromTo, new Color(spriteRoot.color.r, spriteRoot.color.g, spriteRoot.color.b, startA), new Color(spriteRoot.color.r, spriteRoot.color.g, spriteRoot.color.b, destA), new EZAnimation.Interpolator(EZAnimation.linear), time, 0f, null, null);
             }
         }
     }
     SpriteText[] componentsInChildren2 = base.transform.GetComponentsInChildren <SpriteText>(true);
     if (componentsInChildren2 != null)
     {
         SpriteText[] array2 = componentsInChildren2;
         for (int j = 0; j < array2.Length; j++)
         {
             SpriteText spriteText = array2[j];
             if (null != spriteText)
             {
                 FadeText.Do(spriteText, EZAnimation.ANIM_MODE.FromTo, new Color(spriteText.color.r, spriteText.color.g, spriteText.color.b, startA), new Color(spriteText.color.r, spriteText.color.g, spriteText.color.b, destA), new EZAnimation.Interpolator(EZAnimation.linear), time, 0f, null, null);
             }
         }
     }
 }
    public override void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        base.Copy(s, flags);
        if (!(s is UIStateToggleBtn))
        {
            return;
        }
        UIStateToggleBtn uIStateToggleBtn = (UIStateToggleBtn)s;

        if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
        {
            this.defaultState = uIStateToggleBtn.defaultState;
        }
        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
        {
            this.prevTransition = uIStateToggleBtn.prevTransition;
            if (Application.isPlaying)
            {
                this.SetToggleState(uIStateToggleBtn.StateNum);
            }
        }
        if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
        {
            this.scriptWithMethodToInvoke = uIStateToggleBtn.scriptWithMethodToInvoke;
            this.methodToInvoke           = uIStateToggleBtn.methodToInvoke;
            this.whenToInvoke             = uIStateToggleBtn.whenToInvoke;
            this.delay = uIStateToggleBtn.delay;
        }
        if ((flags & ControlCopyFlags.Sound) == ControlCopyFlags.Sound)
        {
            this.soundToPlay = uIStateToggleBtn.soundToPlay;
        }
    }
Exemplo n.º 10
0
    public override void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        base.Copy(s, flags);

        if (!(s is UIListItem))
        {
            return;
        }

        UIListItem b = (UIListItem)s;


        if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
        {
            list = b.list;
        }

        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            topLeftEdge     = b.topLeftEdge;
            bottomRightEdge = b.bottomRightEdge;
            colliderTL      = b.colliderTL;
            colliderBR      = b.colliderBR;
            colliderCenter  = b.colliderCenter;
            customCollider  = b.customCollider;
        }
    }
 public void FadeListItemContainer(float dur)
 {
     SpriteRoot[] componentsInChildren = base.transform.GetComponentsInChildren <SpriteRoot>(true);
     if (componentsInChildren != null)
     {
         SpriteRoot[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             SpriteRoot spriteRoot = array[i];
             if (null != spriteRoot)
             {
                 FadeSprite.Do(spriteRoot, EZAnimation.ANIM_MODE.FromTo, new Color(1f, 1f, 1f, 1f), new Color(1f, 1f, 1f, 0f), new EZAnimation.Interpolator(EZAnimation.linear), dur, 0f, null, null);
             }
         }
     }
     SpriteText[] componentsInChildren2 = base.transform.GetComponentsInChildren <SpriteText>(true);
     if (componentsInChildren2 != null)
     {
         SpriteText[] array2 = componentsInChildren2;
         for (int j = 0; j < array2.Length; j++)
         {
             SpriteText spriteText = array2[j];
             if (null != spriteText)
             {
                 FadeText.Do(spriteText, EZAnimation.ANIM_MODE.FromTo, new Color(1f, 1f, 1f, 1f), new Color(1f, 1f, 1f, 0f), new EZAnimation.Interpolator(EZAnimation.linear), dur, 0f, null, null);
             }
         }
     }
 }
Exemplo n.º 12
0
 public void StopAni()
 {
     SpriteRoot[] componentsInChildren = base.transform.GetComponentsInChildren <SpriteRoot>(true);
     if (componentsInChildren != null)
     {
         SpriteRoot[] array = componentsInChildren;
         for (int i = 0; i < array.Length; i++)
         {
             SpriteRoot spriteRoot = array[i];
             if (null != spriteRoot)
             {
                 EZAnimator.instance.Stop(spriteRoot.gameObject);
                 EZAnimator.instance.Stop(spriteRoot);
             }
         }
     }
     SpriteText[] componentsInChildren2 = base.transform.GetComponentsInChildren <SpriteText>(true);
     if (componentsInChildren2 != null)
     {
         SpriteText[] array2 = componentsInChildren2;
         for (int j = 0; j < array2.Length; j++)
         {
             SpriteText spriteText = array2[j];
             if (null != spriteText)
             {
                 EZAnimator.instance.Stop(spriteText.gameObject);
                 EZAnimator.instance.Stop(spriteText);
             }
         }
     }
 }
Exemplo n.º 13
0
    public override void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        base.Copy(s, flags);
        if (!(s is UIButton))
        {
            return;
        }
        UIButton uIButton = (UIButton)s;

        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
        {
            this.prevTransition = uIButton.prevTransition;
            if (Application.isPlaying)
            {
                this.SetControlState(uIButton.controlState);
            }
        }
        if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
        {
            this.scriptWithMethodToInvoke = uIButton.scriptWithMethodToInvoke;
            this.methodToInvoke           = uIButton.methodToInvoke;
            this.whenToInvoke             = uIButton.whenToInvoke;
            this.delay = uIButton.delay;
        }
        if ((flags & ControlCopyFlags.Sound) == ControlCopyFlags.Sound)
        {
            this.soundOnOver  = uIButton.soundOnOver;
            this.soundOnClick = uIButton.soundOnClick;
        }
        if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
        {
            this.repeat = uIButton.repeat;
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// Copies all the attributes of another sprite,
    /// including its edit-time TextureAnimations.
    /// </summary>
    /// <param name="s">A reference to the sprite to be copied.</param>
    public virtual void CopyAll(SpriteRoot s)
    {
        AutoSpriteBase sp;

        base.Copy(s);

        // Check the type:
        if (!(s is AutoSpriteBase))
        {
            return;
        }

        sp = (AutoSpriteBase)s;

        States = new TextureAnim[sp.States.Length];

        for (int i = 0; i < States.Length; ++i)
        {
            States[i] = new TextureAnim();
            States[i].Copy(sp.States[i]);
        }

        animations = new UVAnimation[States.Length];

        for (int i = 0; i < States.Length; ++i)
        {
            animations[i] = new UVAnimation();
            animations[i].SetAnim(States[i], i);
        }
    }
Exemplo n.º 15
0
    /// <summary>
    /// Copies all the attributes of another sprite.
    /// </summary>
    /// <param name="s">A reference to the sprite to be copied.</param>
    public override void Copy(SpriteRoot s)
    {
        base.Copy(s);

        // Check the type:
        if (!(s is SimpleSprite))
        {
            return;
        }

        lowerLeftPixel  = ((SimpleSprite)s).lowerLeftPixel;
        pixelDimensions = ((SimpleSprite)s).pixelDimensions;

        InitUVs();

        SetBleedCompensation(s.bleedCompensation);

        if (autoResize || pixelPerfect)
        {
            CalcSize();
        }
        else
        {
            SetSize(s.width, s.height);
        }
    }
Exemplo n.º 16
0
 public override void Copy(SpriteRoot s, ControlCopyFlags flags)
 {
     base.Copy(s, flags);
     if (!(s is UIButton))
     {
         return;
     }
 }
Exemplo n.º 17
0
    public override void Mirror(SpriteRoot s)
    {
        AutoSpriteControlBase autoSpriteControlBase = (AutoSpriteControlBase)s;

        base.Mirror(s);
        this.text        = autoSpriteControlBase.Text;
        this.textOffsetZ = autoSpriteControlBase.textOffsetZ;
    }
Exemplo n.º 18
0
    // Mirrors the specified control's settings
    public override void Mirror(SpriteRoot s)
    {
        AutoSpriteControlBase c = (AutoSpriteControlBase)s;

        base.Mirror(s);
        text        = c.text;
        textOffsetZ = c.textOffsetZ;
    }
 public virtual bool Validate(SpriteRoot s)
 {
     if (s.pixelPerfect)
     {
         s.autoResize = true;
     }
     return(true);
 }
Exemplo n.º 20
0
    // Mirrors the specified SpriteText's settings
    public override void Mirror(SpriteRoot s)
    {
        base.Mirror(s);
        UITextField tf = (UITextField)s;

        margins   = tf.margins;
        multiline = tf.multiline;
    }
Exemplo n.º 21
0
 public SPRITE_FRAME[] BuildUVAnim(SpriteRoot s)
 {
     if (this.totalCells < 1)
     {
         return(null);
     }
     return(base.BuildUVAnim(s.PixelCoordToUVCoord(this.start), s.PixelSpaceToUVSpace(this.pixelsToNextColumnAndRow), this.cols, this.rows, this.totalCells));
 }
Exemplo n.º 22
0
	/// <summary>
	/// Adds the sprite attached to the specified GameObject
	/// to the SpriteManager.
	/// </summary>
	/// <param name="go">GameObject containing a sprite.</param>
	/// <returns>A reference to the sprite's managed mesh.</returns>
	public SpriteMesh_Managed AddSprite(GameObject go)
	{
		SpriteRoot sprite = (SpriteRoot)go.GetComponent(typeof(SpriteRoot));
		if (sprite == null)
			return null;

		return AddSprite(sprite);
	}
    public override void Mirror(SpriteRoot s)
    {
        base.Mirror(s);
        UITextField uITextField = (UITextField)s;

        this.margins   = uITextField.margins;
        this.multiline = uITextField.multiline;
    }
 protected virtual void HandleDrawLayerChange(SpriteRoot s)
 {
     if (!s.managed)
     {
         s.drawLayer = 0;
         return;
     }
     s.SetDrawLayer(s.drawLayer);
 }
Exemplo n.º 25
0
    /// <summary>
    /// Shows the attribute tips by the SpriteRoot (PackedSprite\UIButton\....)
    /// </summary>
    /// <param name='sprite'>
    /// Sprite.
    /// </param>
    /// <param name='title'>
    /// Title.
    /// </param>
    /// <param name='desc'>
    /// Desc.
    /// </param>
    public void ShowAttributeTips(SpriteRoot sprite, string title, string desc)
    {
        if (mAttributeTipInstance == null)
        {
            mAttributeTipInstance = (AttributeTipBubble)Instantiate(AttributeTipPrefab);
        }

        mAttributeTipInstance.ShowAttrTips(sprite, title, desc);
    }
Exemplo n.º 26
0
    public override void Copy(SpriteRoot s, ControlCopyFlags flags)
    {
        base.Copy(s, flags);

        if (!(s is UITextField))
        {
            return;
        }

        UITextField b = (UITextField)s;


        if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
        {
            maxLength        = b.maxLength;
            multiline        = b.multiline;
            password         = b.password;
            maskingCharacter = b.maskingCharacter;
            customKeyboard   = b.customKeyboard;
            customFocusEvent = b.customFocusEvent;
            margins          = b.margins;

#if UNITY_IPHONE || UNITY_ANDROID
            type        = b.type;
            autoCorrect = b.autoCorrect;
            alert       = b.alert;
            hideInput   = b.hideInput;
#endif
            typingSoundEffect = b.typingSoundEffect;
            fieldFullSound    = b.fieldFullSound;
        }

        if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
        {
            scriptWithMethodToInvoke = b.scriptWithMethodToInvoke;
            methodToInvoke           = b.methodToInvoke;
        }

        if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
        {
            caret.Copy(b.caret);

            caretSize         = b.caretSize;
            caretOffset       = b.caretOffset;
            caretAnchor       = b.caretAnchor;
            showCaretOnMobile = b.showCaretOnMobile;
        }

        if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
        {
            insert = b.insert;
            Text   = b.Text;
        }

        SetMargins(margins);
    }
Exemplo n.º 27
0
	// Use this for initialization
	void Start()
	{
		sprite = gameObject.GetComponent<SpriteRoot>();
		
#if !UNITY_EDITOR
		sprite.width = ( sprite.RenderCamera.orthographicSize * sprite.RenderCamera.aspect * 2.0f) * sizeX;
		sprite.height = sprite.RenderCamera.orthographicSize * 2.0f * sizeY;
		sprite.CalcSize();
#endif
	}
Exemplo n.º 28
0
    public SpriteMesh_Managed AddSprite(GameObject go)
    {
        SpriteRoot spriteRoot = (SpriteRoot)go.GetComponent(typeof(SpriteRoot));

        if (spriteRoot == null)
        {
            return(null);
        }
        return(this.AddSprite(spriteRoot));
    }
Exemplo n.º 29
0
 /// <summary>
 /// ルートの初期化
 /// </summary>
 /// <param name="root"></param>
 /// <param name="information"></param>
 /// <param name="settings"></param>
 /// <param name="requiredCellMap"></param>
 private static void InitializeRoot(SpriteRoot root, SSPJImporter.Information information,
                                    SSAEImporter.OverrideSettings settings,
                                    List <CellMap> requiredCellMap)
 {
     root.Setup(Pick(information.fps, settings.fps),
                Pick(information.frameCount, settings.frameCount),
                Pick(information.pivotX, settings.pivotX),
                Pick(information.pivotY, settings.pivotY));
     root.SetupSpriteHolder();
     root.SetupCellMaps(requiredCellMap);
 }
Exemplo n.º 30
0
 public UVAnimation_Auto[] BuildUVAnim(SpriteRoot s)
 {
     this.i = 0;
     while (this.i < this.clips.Length)
     {
         this.clips[this.i].BuildUVAnim(s);
         this.i++;
     }
     this.CalcDuration();
     return(this.clips);
 }
Exemplo n.º 31
0
    public override void Copy(SpriteRoot s)
    {
        base.Copy(s);
        if (!(s is SpriteBase))
        {
            return;
        }
        SpriteBase spriteBase = (SpriteBase)s;

        this.defaultAnim     = spriteBase.defaultAnim;
        this.playAnimOnStart = spriteBase.playAnimOnStart;
    }
Exemplo n.º 32
0
	public override void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		base.Copy(s, flags);

		if (!(s is UIBtnWWW))
			return;

		UIBtnWWW b = (UIBtnWWW)s;

		if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
		{
			URL = b.URL;
		}
	}
Exemplo n.º 33
0
	public override void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		base.Copy(s, flags);

		if (!(s is UIBtnLoadScene))
			return;

		UIBtnLoadScene b = (UIBtnLoadScene)s;

		if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
		{
			scene = b.scene;
			loadingPanel = b.loadingPanel;
		}
	}
Exemplo n.º 34
0
    /// <summary>
    /// Copies all the attributes of another sprite.
    /// </summary>
    /// <param name="s">A reference to the sprite to be copied.</param>
    public override void Copy(SpriteRoot s)
    {
        base.Copy(s);

        // Check the type:
        if (!(s is SimpleSprite))
            return;

        lowerLeftPixel = ((SimpleSprite)s).lowerLeftPixel;
        pixelDimensions = ((SimpleSprite)s).pixelDimensions;

        InitUVs();

        SetBleedCompensation(s.bleedCompensation);

        if (autoResize || pixelPerfect)
            CalcSize();
        else
            SetSize(s.width, s.height);
    }
Exemplo n.º 35
0
	public static Vector2 GetPositionFromParentSprite (SpriteRoot parentSprite, Vector2 percentage)
	{
		switch (parentSprite.anchor)
		{	
			case SpriteRoot.ANCHOR_METHOD.TEXTURE_OFFSET:
				return new Vector2 (GetCenter (parentSprite, percentage), GetMiddle (parentSprite, percentage));
				
			//UPPERS
			case SpriteRoot.ANCHOR_METHOD.UPPER_LEFT:
				return new Vector2 (GetLeft (parentSprite, percentage), GetUpper (parentSprite, percentage));
				
			case SpriteRoot.ANCHOR_METHOD.UPPER_CENTER:
				return new Vector2 (GetCenter (parentSprite, percentage), GetUpper (parentSprite, percentage));
				
			case SpriteRoot.ANCHOR_METHOD.UPPER_RIGHT:
				return new Vector2 (GetRight (parentSprite, percentage), GetUpper (parentSprite, percentage));
				
			//MIDDLES
			case SpriteRoot.ANCHOR_METHOD.MIDDLE_LEFT:
				return new Vector2 (GetLeft (parentSprite, percentage), GetMiddle (parentSprite, percentage));
				
			case SpriteRoot.ANCHOR_METHOD.MIDDLE_CENTER:
				return new Vector2 (GetCenter (parentSprite, percentage), GetMiddle (parentSprite, percentage));
				
			case SpriteRoot.ANCHOR_METHOD.MIDDLE_RIGHT:
				return new Vector2 (GetRight (parentSprite, percentage), GetMiddle (parentSprite, percentage));
				
			//BOTTOMS
			case SpriteRoot.ANCHOR_METHOD.BOTTOM_LEFT:
				return new Vector2 (GetLeft (parentSprite, percentage), GetBottom (parentSprite, percentage));
				
			case SpriteRoot.ANCHOR_METHOD.BOTTOM_CENTER:
				return new Vector2 (GetCenter (parentSprite, percentage), GetBottom (parentSprite, percentage));
				
			case SpriteRoot.ANCHOR_METHOD.BOTTOM_RIGHT:
				return new Vector2 (GetRight (parentSprite, percentage), GetBottom (parentSprite, percentage));	
		}
		
		ScreenLog.AddMessage("UNKNOWN ERROR! SHOULDNT REACH THIS CODE", ScreenLogType.Error);
		return Vector2.zero;
	}
Exemplo n.º 36
0
	/// <summary>
	/// Copies all the attributes of another sprite.
	/// </summary>
	/// <param name="s">A reference to the sprite to be copied.</param>
	public override void Copy(SpriteRoot s)
	{
		base.Copy(s);

		PackedSprite sp;

		// Check the type:
		if (!(s is PackedSprite))
			return;

		sp = (PackedSprite)s;

		if (!sp.m_started)
			staticFrameInfo = sp._ser_stat_frame_info.ToStruct();
		else
			staticFrameInfo = sp.staticFrameInfo;

		if (curAnim != null)
		{
			if (curAnim.index == -1)
				PlayAnim(curAnim);
			else
				SetState(curAnim.index);
		}
		else
		{
			frameInfo = staticFrameInfo;
			uvRect = frameInfo.uvs;

			if (autoResize || pixelPerfect)
				CalcSize();
			else
				SetSize(s.width, s.height);
		}

		SetBleedCompensation();
	}
Exemplo n.º 37
0
	/// <summary>
	/// Copies all the attributes of another sprite.
	/// </summary>
	/// <param name="s">A reference to the sprite to be copied.</param>
	public override void Copy(SpriteRoot s)
	{
		AutoSpriteBase sp;

		base.Copy(s);

		// Check the type:
		if (!(s is AutoSpriteBase))
			return;

		sp = (AutoSpriteBase)s;

		// See if it is an actual sprite instance:
		if (sp.spriteMesh != null)
		{
			if (sp.animations.Length > 0)
			{
				animations = new UVAnimation[sp.animations.Length];
				for (int i = 0; i < animations.Length; ++i)
					animations[i] = sp.animations[i].Clone();
			}
		}
		else if (States != null)
		{
			// Assume this is a prefab, so copy the UV info 
			//from its TextureAnimations instead:			
			animations = new UVAnimation[sp.States.Length];

			for (int i = 0; i < sp.States.Length; ++i)
			{
				animations[i] = new UVAnimation();
				animations[i].SetAnim(sp.States[i], i);
			}
		}
	}
Exemplo n.º 38
0
	public override void Copy(SpriteRoot s)
	{
		Copy(s, ControlCopyFlags.All);
	}
Exemplo n.º 39
0
	public override void Start()
	{
		if (m_started)
			return;

		base.Start();

		// Check for any existing empty bar and destroy it:
		if (emptySprite != null)
		{
			Destroy(emptySprite);
			emptySprite = null;
		}

		// Assign our aggregate layers:
		aggregateLayers = new SpriteRoot[2][];
		aggregateLayers[0] = filledLayers;
		aggregateLayers[1] = emptyLayers;

		// Runtime init stuff:
		if(Application.isPlaying)
		{
			filledIndices = new int[filledLayers.Length];
			emptyIndices = new int[emptyLayers.Length];

			// Populate our state indices based on if we
			// find any valid states/animations in each 
			// sprite layer:
			for (int i = 0; i < filledLayers.Length; ++i)
			{
				if (filledLayers[i] == null)
				{
					Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
					continue;
				}

				filledIndices[i] = filledLayers[i].GetStateIndex("filled");
				if (filledIndices[i] != -1)
					filledLayers[i].SetState(filledIndices[i]);
			}
			for (int i = 0; i < emptyLayers.Length; ++i)
			{
				if (emptyLayers[i] == null)
				{
					Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
					continue;
				}

				emptyIndices[i] = emptyLayers[i].GetStateIndex("empty");
				if (emptyIndices[i] != -1)
					emptyLayers[i].SetState(emptyIndices[i]);
			}

			// Create our other sprite for the 
			// empty/background portion:
			GameObject emptyObj = new GameObject();
			emptyObj.name = name + " - Empty Bar";
			emptyObj.transform.parent = transform;
			emptyObj.transform.localPosition = Vector3.zero;
			emptyObj.transform.localScale = Vector3.one;
			emptyObj.transform.localRotation = Quaternion.identity;
			emptyObj.layer = gameObject.layer;
			emptySprite = (AutoSprite)emptyObj.AddComponent(typeof(AutoSprite));
			emptySprite.plane = plane;
			emptySprite.autoResize = autoResize;
			emptySprite.pixelPerfect = pixelPerfect;
			emptySprite.persistent = persistent;
			emptySprite.ignoreClipping = ignoreClipping;
			emptySprite.bleedCompensation = bleedCompensation;
			if (!managed)
				emptySprite.renderer.sharedMaterial = renderer.sharedMaterial;
			else
			{
				if (manager != null)
				{
					emptySprite.Managed = managed;
					manager.AddSprite(emptySprite);
					emptySprite.SetDrawLayer(drawLayer);	// Knob should be drawn in front of the bar
				}
				else
					Debug.LogError("Sprite on object \"" + name + "\" not assigned to a SpriteManager!");
			}
			emptySprite.color = color;
			emptySprite.SetAnchor(anchor);
			emptySprite.Setup(width, height, m_spriteMesh.material);
			if (states[1].spriteFrames.Length != 0)
			{
				emptySprite.animations = new UVAnimation[1];
				emptySprite.animations[0] = new UVAnimation();
				emptySprite.animations[0].SetAnim(states[1], 0);
				emptySprite.PlayAnim(0, 0);
			}
			emptySprite.renderCamera = renderCamera;
			emptySprite.Hide(IsHidden());

			Value = m_value;

			if (container != null)
				container.AddChild(emptyObj);

			SetState(0);
		}

		// Since hiding while managed depends on
		// setting our mesh extents to 0, and the
		// foregoing code causes us to not be set
		// to 0, re-hide ourselves:
		if (managed && m_hidden)
			Hide(true);
	}
Exemplo n.º 40
0
	public virtual void SetWindingOrder(SpriteRoot.WINDING_ORDER winding)
	{
/*		Commented out because this should now be taken care of
 *		by the fact we now reverse the x position of the vertices.
 * 
		if (winding == SpriteRoot.WINDING_ORDER.CCW)
		{
			// Counter-clockwise:
			m_faces[0] = 0;	//	0_ 2			0 ___ 3
			m_faces[1] = 1;	//  | /		Verts:	 |	/|
			m_faces[2] = 3;	// 1|/				1|/__|2

			m_faces[3] = 3;	//	  3
			m_faces[4] = 1;	//   /|
			m_faces[5] = 2;	// 4/_|5
		}
		else
*/
		{
			// Clock-wise:
			m_faces[0] = 0;	//	0_ 1			0 ___ 3
			m_faces[1] = 3;	//  | /		Verts:	 |	/|
			m_faces[2] = 1;	// 2|/				1|/__|2

			m_faces[3] = 3;	//	  3
			m_faces[4] = 2;	//   /|
			m_faces[5] = 1;	// 5/_|4
		}

		if (m_mesh != null)
			m_mesh.triangles = m_faces;
	}
Exemplo n.º 41
0
	public override void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		base.Copy(s, flags);

		if (!(s is UISlider))
			return;

		UISlider b = (UISlider)s;


		if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
		{
			scriptWithMethodToInvoke = b.scriptWithMethodToInvoke;
			methodToInvoke = b.methodToInvoke;
		}

		if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
		{
			defaultValue = b.defaultValue;
			stopKnobFromEdge = b.stopKnobFromEdge;
			knobOffset = b.knobOffset;
			knobSize = b.knobSize;
			knobColliderSizeFactor = b.knobColliderSizeFactor;
		}

		if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
		{
			if (Application.isPlaying)
			{
				if (emptySprite != null)
					emptySprite.Copy(b.emptySprite);

				if (knob != null)
					knob.Copy(b.knob);

				truncFloor = b.truncFloor;
				truncRange = b.truncRange;
			}
		}

		if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
		{
			CalcKnobStartPos();
			Value = b.Value;
		}
	}
Exemplo n.º 42
0
	// Mirrors the specified control's settings
	public override void Mirror(SpriteRoot s)
	{
		AutoSpriteControlBase c = (AutoSpriteControlBase)s;

		base.Mirror(s);
		text = c.text;
		textOffsetZ = c.textOffsetZ;
	}
Exemplo n.º 43
0
	public override void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		base.Copy(s, flags);

		if (!(s is UIStateToggleBtn))
			return;

		UIStateToggleBtn b = (UIStateToggleBtn)s;

		if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
		{
			defaultState = b.defaultState;
		}

		if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
		{
			prevTransition = b.prevTransition;

			if (Application.isPlaying)
				SetToggleState(b.StateNum);
		}

		if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
		{
			scriptWithMethodToInvoke = b.scriptWithMethodToInvoke;
			methodToInvoke = b.methodToInvoke;
			whenToInvoke = b.whenToInvoke;
			delay = b.delay;
		}

		if ((flags & ControlCopyFlags.Sound) == ControlCopyFlags.Sound)
		{
			soundToPlay = b.soundToPlay;
		}
	}
Exemplo n.º 44
0
	private static float GetMiddle (SpriteRoot parentSprite, Vector2 percentage)
	{
		return parentSprite.height * (-percentage.y / 100) + (parentSprite.height / 2);
	}
Exemplo n.º 45
0
	public override void Start()
	{
		if (m_started)
			return;

		base.Start();

		// Assign our aggregate layers:
		aggregateLayers = new SpriteRoot[1][];
		aggregateLayers[0] = layers;

		state = controlIsEnabled ? (btnValue ? CONTROL_STATE.True : CONTROL_STATE.False) : CONTROL_STATE.Disabled;
/*
		if (btnValue)
			PopOtherButtonsInGroup();
*/

		// Runtime init stuff:
		if (Application.isPlaying)
		{
			// Setup our transitions:
			for (int i = 0; i < transitions.Length; ++i)
				for (int j = 0; j < transitions[i].list.Length; ++j)
				{
					transitions[i].list[j].MainSubject = this.gameObject;

					// Add our text as a sub-subject of our transitions:
					if (spriteText != null)
						transitions[i].list[j].AddSubSubject(spriteText.gameObject);
				}

			// Add our text as a sub-subject of our transitions:

			stateIndices = new int[layers.Length, 5];

			// We'll use this to setup our state:
			int stateIdx = btnValue ? 0 : 1;
			stateIdx = m_controlIsEnabled ? stateIdx : 2;

			// Populate our state indices based on if we
			// find any valid states/animations in each 
			// sprite layer:
			for (int i = 0; i < layers.Length; ++i)
			{
				if (layers[i] == null)
				{
					Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
					continue;
				}

				stateIndices[i, 0] = layers[i].GetStateIndex("true");
				stateIndices[i, 1] = layers[i].GetStateIndex("false");
				stateIndices[i, 2] = layers[i].GetStateIndex("disabled");
				stateIndices[i, 3] = layers[i].GetStateIndex("over");
				stateIndices[i, 4] = layers[i].GetStateIndex("active");

				// Add this as a subject of our transition for 
				// each state, as appropriate:
				if (stateIndices[i, 0] != -1)
				{
					transitions[0].list[0].AddSubSubject(layers[i].gameObject);
					transitions[0].list[1].AddSubSubject(layers[i].gameObject);
				}
				if (stateIndices[i, 1] != -1)
				{
					transitions[1].list[0].AddSubSubject(layers[i].gameObject);
					transitions[1].list[1].AddSubSubject(layers[i].gameObject);
				}
				if (stateIndices[i, 2] != -1)
				{
					transitions[2].list[0].AddSubSubject(layers[i].gameObject);
					transitions[2].list[1].AddSubSubject(layers[i].gameObject);
				}

				// Set the layer's state:
				if (stateIndices[i, stateIdx] != -1)
					layers[i].SetState(stateIndices[i, stateIdx]);
				else
					layers[i].Hide(true);
			}

			// Create a default collider if none exists:
			if (collider == null)
				AddCollider();

			SetValue(btnValue, true);

			if (useParentForGrouping && transform.parent != null)
				SetGroup(transform.parent.GetHashCode());
			else
				SetGroup(radioGroup);
		}

		// Since hiding while managed depends on
		// setting our mesh extents to 0, and the
		// foregoing code causes us to not be set
		// to 0, re-hide ourselves:
		if (managed && m_hidden)
			Hide(true);
	}
Exemplo n.º 46
0
	/// <summary>
	/// Builds the UV animations for all animation clips
	/// that are a part of this animation sequence.
	/// </summary>
	/// <param name="s">The sprite for which to build the animation.</param>
	/// <returns>Array of animation clips that constitute the animation sequence.</returns>
	public UVAnimation_Auto[] BuildUVAnim(SpriteRoot s)
	{
		for (i = 0; i < clips.Length; ++i)
		{
			clips[i].BuildUVAnim(s);
		}

		CalcDuration();

		return clips;
	}
Exemplo n.º 47
0
	/// <summary>
	/// Uses the information stored in this class to build
	/// a UV animation for the specified sprite.
	/// </summary>
	/// <param name="s">The sprite for which the animation will be built.</param>
	/// <returns>An array of ANIM_FRAMEs that define the animation.</returns>
	public SPRITE_FRAME[] BuildUVAnim(SpriteRoot s)
	{
		if (totalCells < 1)
			return null;

		return this.BuildUVAnim(s.PixelCoordToUVCoord(start), s.PixelSpaceToUVSpace(pixelsToNextColumnAndRow), cols, rows, totalCells);
	}
Exemplo n.º 48
0
	public override void Copy(SpriteRoot s)
	{
		base.Copy(s);

		if (!(s is SpriteBase))
			return;

		SpriteBase sb = (SpriteBase)s;

		defaultAnim = sb.defaultAnim;
		playAnimOnStart = sb.playAnimOnStart;
	}
Exemplo n.º 49
0
	/// <summary>
	/// Copies all the attributes of another sprite,
	/// including its edit-time TextureAnimations.
	/// </summary>
	/// <param name="s">A reference to the sprite to be copied.</param>
	public virtual void CopyAll(SpriteRoot s)
	{
		AutoSpriteBase sp;

		base.Copy(s);

		// Check the type:
		if (!(s is AutoSpriteBase))
			return;

		sp = (AutoSpriteBase)s;

		States = new TextureAnim[sp.States.Length];

		for (int i = 0; i < States.Length; ++i)
		{
			States[i] = new TextureAnim();
			States[i].Copy(sp.States[i]);
		}

		animations = new UVAnimation[States.Length];

		for (int i = 0; i < States.Length; ++i)
		{
			animations[i] = new UVAnimation();
			animations[i].SetAnim(States[i], i);
		}

		doNotTrimImages = sp.doNotTrimImages;
	}
Exemplo n.º 50
0
	// Returns true if any of the settings do not match:
	public override bool DidChange(SpriteRoot s)
	{
		AutoSpriteControlBase c = (AutoSpriteControlBase)s;

		if (text != c.text)
		{
			c.Text = c.text;
			return true;
		}

		if (textOffsetZ != c.textOffsetZ)
		{
			if (c.spriteText != null)
				c.spriteText.offsetZ = textOffsetZ;
			return true;
		}

		return base.DidChange(s);
	}
Exemplo n.º 51
0
	public override void Start()
	{
		if (m_started)
			return;

		base.Start();

		// Assign our aggregate layers:
		aggregateLayers = new SpriteRoot[1][];
		aggregateLayers[0] = layers;

		// Runtime init stuff:
		if (Application.isPlaying)
		{
			// Add 3 additional states:
			// +1 - Disabled state
			// +1 - Over state (only supported by layers)
			// +1 - Active state (only supported by layers)
			stateIndices = new int[layers.Length, states.Length + 3];

			// Assign our "Over" and "Active" layer state indices:
			overLayerState = states.Length + 1;
			activeLayerState = states.Length + 2;

			// Populate our state indices based on if we
			// find any valid states/animations in each 
			// sprite layer:
			int j, i;
			for (j = 0; j < states.Length; ++j)
			{
				// Setup the transition:
				transitions[j].list[0].MainSubject = this.gameObject;

				for (i = 0; i < layers.Length; ++i)
				{
					if (layers[i] == null)
					{
						Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
						continue;
					}

					stateIndices[i, j] = layers[i].GetStateIndex(states[j].name);

					// Set the layer's state:
					if (stateIndices[i, curStateIndex] != -1)
						layers[i].SetState(stateIndices[i, curStateIndex]);
					else
						layers[i].Hide(true);

					// Add this as a subject of our transition for 
					// each state, as appropriate:
					if (stateIndices[i, j] != -1)
						transitions[j].list[0].AddSubSubject(layers[i].gameObject);
				}

				// Add our text as a sub-subject of our transition as well:
				if (spriteText != null)
					transitions[j].list[0].AddSubSubject(spriteText.gameObject);
			}

			// Loop once more to add our "Over" and "Active"
			// state support for our layers:
			for (i = 0; i < layers.Length; ++i)
			{
				stateIndices[i, overLayerState] = layers[i].GetStateIndex("Over");
				stateIndices[i, activeLayerState] = layers[i].GetStateIndex("Active");
			}

			// Create a default collider if none exists:
			if (collider == null)
				AddCollider();

			SetToggleState(curStateIndex, true);
		}

		// Since hiding while managed depends on
		// setting our mesh extents to 0, and the
		// foregoing code causes us to not be set
		// to 0, re-hide ourselves:
		if (managed && m_hidden)
			Hide(true);
	}
Exemplo n.º 52
0
	/// <summary>
	/// Copies all of the specified control's settings
	/// to this control, provided they are of the same
	/// type.  One exception is that layers are not
	/// copied as this would require a new allocation
	/// and could negatively impact performance at
	/// runtime.
	/// </summary>
	/// <param name="s">Reference to the control whose settings are to be copied to this control.</param>
	public virtual void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
		{
			if (Application.isPlaying && s.Started)
				base.Copy(s);
			else // If we're in-editor, copy the TextureAnims too
				base.CopyAll(s);

			if (!(s is AutoSpriteControlBase))
			{
				if (autoResize || pixelPerfect)
					CalcSize();
				else
					SetSize(s.width, s.height);

				SetBleedCompensation();

				return;
			}
		}



		AutoSpriteControlBase c = (AutoSpriteControlBase)s;

		// Copy transitions:
		if ((flags & ControlCopyFlags.Transitions) == ControlCopyFlags.Transitions)
		{
			if (c is UIStateToggleBtn || !Application.isPlaying)
			{
				if (c.Transitions != null)
				{
					Transitions = new EZTransitionList[c.Transitions.Length];
					for (int i = 0; i < Transitions.Length; ++i)
					{
						Transitions[i] = new EZTransitionList();
						c.Transitions[i].CopyToNew(Transitions[i], true);
					}
				}
			}
			else
			{
				if (Transitions != null && c.Transitions != null)
					for (int i = 0; i < Transitions.Length && i < c.Transitions.Length; ++i)
						c.Transitions[i].CopyTo(Transitions[i], true);
			}
		}


		if ((flags & ControlCopyFlags.Text) == ControlCopyFlags.Text)
		{
			// See if we want to clone the other
			// control's text mesh:
			if (spriteText == null && c.spriteText != null)
			{
				GameObject newText = (GameObject)Instantiate(c.spriteText.gameObject);
				newText.transform.parent = transform;
				newText.transform.localPosition = c.spriteText.transform.localPosition;
				newText.transform.localScale = c.spriteText.transform.localScale;
				newText.transform.localRotation = c.spriteText.transform.localRotation;
			}

			if (spriteText != null)
				spriteText.Copy(c.spriteText);

			text = c.text;
			textOffsetZ = c.textOffsetZ;
			includeTextInAutoCollider = c.includeTextInAutoCollider;
		}

		if ((flags & ControlCopyFlags.Data) == ControlCopyFlags.Data)
		{
			data = c.data;
		}

		if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
		{
			// See if we can copy the other control's collider's settings:
			if (c.collider != null)
			{
				// See if we don't already have a collider, in which case,
				// duplicate the one of the control being copied:
				if (collider == null)
				{
					gameObject.AddComponent(c.collider.GetType());
					customCollider = c.customCollider;
				}

				if (collider.GetType() == c.collider.GetType())
				{
					if (c.collider is BoxCollider)
					{
						if (collider == null)
							gameObject.AddComponent(typeof(BoxCollider));

						BoxCollider bc1 = (BoxCollider)collider;
						BoxCollider bc2 = (BoxCollider)c.collider;
						bc1.center = bc2.center;
						bc1.size = bc2.size;
					}
					else if (c.collider is SphereCollider)
					{
						if (collider == null)
							gameObject.AddComponent(typeof(SphereCollider));

						SphereCollider sc1 = (SphereCollider)collider;
						SphereCollider sc2 = (SphereCollider)c.collider;
						sc1.center = sc2.center;
						sc1.radius = sc2.radius;
					}
					else if (c.collider is MeshCollider)
					{
						if (collider == null)
							gameObject.AddComponent(typeof(MeshCollider));

						MeshCollider mc1 = (MeshCollider)collider;
						MeshCollider mc2 = (MeshCollider)c.collider;
						mc1.smoothSphereCollisions = mc2.smoothSphereCollisions;
						mc1.convex = mc2.convex;
						mc1.sharedMesh = mc2.sharedMesh;
					}
					else if (c.collider is CapsuleCollider)
					{
						if (collider == null)
							gameObject.AddComponent(typeof(CapsuleCollider));

						CapsuleCollider cc1 = (CapsuleCollider)collider;
						CapsuleCollider cc2 = (CapsuleCollider)c.collider;
						cc1.center = cc2.center;
						cc1.radius = cc2.radius;
						cc1.height = cc2.height;
						cc1.direction = cc2.direction;
					}

					if (collider != null)
						collider.isTrigger = c.collider.isTrigger;
				}
			}
			else if (Application.isPlaying) // Don't create a collider if we're in edit mode
			{
				// Create a default box collider to fit so
				// long as the control isn't of 0 size:
				if (collider == null &&
					width != 0 && height != 0 &&
					!float.IsNaN(width) && !float.IsNaN(height))
				{
					BoxCollider bc = (BoxCollider)gameObject.AddComponent(typeof(BoxCollider));
					bc.size = new Vector3(c.width, c.height, 0.001f);
					bc.center = c.GetCenterPoint();
					bc.isTrigger = true;
				}
				else
				{
					if (collider is BoxCollider)
					{
						BoxCollider bc = (BoxCollider)collider;
						bc.size = new Vector3(c.width, c.height, 0.001f);
						bc.center = c.GetCenterPoint();
					}
					else if (collider is SphereCollider)
					{
						SphereCollider sc = (SphereCollider)collider;
						sc.radius = Mathf.Max(c.width, c.height);
						sc.center = c.GetCenterPoint();
					}
					// Else Fuhgettaboutit
				}
			}
		}

		if ((flags & ControlCopyFlags.DragDrop) == ControlCopyFlags.DragDrop)
		{
			isDraggable = c.isDraggable;
			dragOffset = c.dragOffset;
			cancelDragEasing = c.cancelDragEasing;
			cancelDragDuration = c.cancelDragDuration;
		}

		if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
		{
			detargetOnDisable = c.detargetOnDisable;
		}

		if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
		{
			changeDelegate = c.changeDelegate;
			inputDelegate = c.inputDelegate;
		}

		if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State ||
			(flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
		{
			Container = c.Container;

			if (Application.isPlaying)
			{
				controlIsEnabled = c.controlIsEnabled;
				Hide(c.IsHidden());
			}

			if (curAnim != null)
			{
				if (curAnim.index == -1)
				{
					if (c.curAnim != null)
						curAnim = c.curAnim.Clone();
					PlayAnim(curAnim);

				}
				else
					SetState(curAnim.index);
			}
			else
				SetState(0);
		}
		/*
				if (autoResize || pixelPerfect)
					CalcSize();
				else
					SetSize(s.width, s.height);
		*/
	}
Exemplo n.º 53
0
	public override void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		base.Copy(s, flags);

		if (!(s is UIRadioBtn))
			return;

		UIRadioBtn b = (UIRadioBtn)s;

		if ((flags & ControlCopyFlags.State) == ControlCopyFlags.State)
		{
			state = b.state;
			prevTransition = b.prevTransition;
			if (Application.isPlaying)
				Value = b.Value;
		}

		if ((flags & ControlCopyFlags.Settings) == ControlCopyFlags.Settings)
		{
			group = b.group;
			defaultValue = b.defaultValue;
		}

		if ((flags & ControlCopyFlags.Invocation) == ControlCopyFlags.Invocation)
		{
			scriptWithMethodToInvoke = b.scriptWithMethodToInvoke;
			methodToInvoke = b.methodToInvoke;
			whenToInvoke = b.whenToInvoke;
			delay = b.delay;
		}

		if ((flags & ControlCopyFlags.Sound) == ControlCopyFlags.Sound)
		{
			soundToPlay = b.soundToPlay;
		}
	}
Exemplo n.º 54
0
	protected override void Start()
	{
		base.Start();

		// Assign our aggregate layers:
		aggregateLayers = new SpriteRoot[1][];
		aggregateLayers[0] = layers;

		// Runtime init stuff:
		if (Application.isPlaying)
		{
			//---
			stateIndices = new int[layers.Length, states.Length+1];

			// Populate our state indices based on if we
			// find any valid states/animations in each 
			// sprite layer:
			int j, i;
			for (j = 0; j < states.Length; ++j)				
			{
				// Setup the transition:
				transitions[j].list[0].MainSubject = this.gameObject;

				for (i = 0; i < layers.Length; ++i)
				{
					if (layers[i] == null)
					{
						Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
						continue;
					}

					stateIndices[i, j] = layers[i].GetStateIndex(states[j].name);

					// Set the layer's state:
					if (stateIndices[i, curStateIndex] != -1)
						layers[i].SetState(stateIndices[i, curStateIndex]);
					else
						layers[i].Hide(true);

					// Add this as a subject of our transition for 
					// each state, as appropriate:
					if (stateIndices[i, j] != -1)
						transitions[j].list[0].AddSubSubject(layers[i].gameObject);
				}
			}

			// Create a default collider if none exists:
			if (collider == null)
				AddCollider();

			SetToggleState(curStateIndex);
		}
	}
Exemplo n.º 55
0
	public override void Start()
	{
		if (m_started)
			return;

		base.Start();

		// Assign our aggregate layers:
		aggregateLayers = new SpriteRoot[2][];
		aggregateLayers[0] = filledLayers;
		aggregateLayers[1] = emptyLayers;
		// The knob will handle its own layers

		// Runtime init stuff:
		if(Application.isPlaying)
		{
			// Calculate our truncation floor and range:
			truncFloor = stopKnobFromEdge / width;
			truncRange = 1f - truncFloor * 2f;

			filledIndices = new int[filledLayers.Length];
			emptyIndices = new int[emptyLayers.Length];

			// Populate our state indices based on if we
			// find any valid states/animations in each 
			// sprite layer:
			for (int i = 0; i < filledLayers.Length; ++i)
			{
				if (filledLayers[i] == null)
				{
					Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
					continue;
				}

				filledIndices[i] = filledLayers[i].GetStateIndex("filled");
				if (filledIndices[i] != -1)
					filledLayers[i].SetState(filledIndices[i]);
			}
			for (int i = 0; i < emptyLayers.Length; ++i)
			{
				if (emptyLayers[i] == null)
				{
					Debug.LogError("A null layer sprite was encountered on control \"" + name + "\". Please fill in the layer reference, or remove the empty element.");
					continue;
				}

				emptyIndices[i] = emptyLayers[i].GetStateIndex("empty");
				if (emptyIndices[i] != -1)
					emptyLayers[i].SetState(emptyIndices[i]);
			}

			// Create our knob:
			GameObject go = new GameObject();
			go.name = name + " - Knob";
			go.transform.parent = transform;
			go.transform.localPosition = CalcKnobStartPos();
			go.transform.localRotation = Quaternion.identity;
			go.transform.localScale = Vector3.one;
			go.layer = gameObject.layer;
			knob = (UIScrollKnob) go.AddComponent(typeof(UIScrollKnob));
			knob.plane = plane;
			knob.SetOffset(knobOffset);
			knob.persistent = persistent;
			knob.bleedCompensation = bleedCompensation;
			if (!managed)
			{
				if (knob.spriteMesh != null)
					((SpriteMesh)knob.spriteMesh).material = renderer.sharedMaterial;
			}
			else
			{
				if (manager != null)
				{
					knob.Managed = managed;
					manager.AddSprite(knob);
					knob.SetDrawLayer(drawLayer + 1);	// Knob should be drawn in front of the bar
				}
				else
					Debug.LogError("Sprite on object \"" + name + "\" not assigned to a SpriteManager!");
			}

			knob.autoResize = autoResize;
			if (pixelPerfect)
			{
				knob.pixelPerfect = true;

			}
			else
				knob.SetSize(knobSize.x, knobSize.y);

			knob.ignoreClipping = ignoreClipping;

			knob.color = color;
			knob.SetColliderSizeFactor(knobColliderSizeFactor);
			knob.SetSlider(this);
			knob.SetMaxScroll(width - (stopKnobFromEdge * 2f));
			knob.SetInputDelegate(inputDelegate);
			// Setup knob's transitions:
			knob.transitions[0] = transitions[2];
			knob.transitions[1] = transitions[3];
			knob.transitions[2] = transitions[4];

			// Tell the knob what it will look like:
			knob.layers = knobLayers;
			// Child the knob's layers to the knob:
			for (int i = 0; i < knobLayers.Length; ++i)
				knobLayers[i].transform.parent = knob.transform;
			knob.animations[0].SetAnim(states[2], 0);
			knob.animations[1].SetAnim(states[3], 1);
			knob.animations[2].SetAnim(states[4], 2);

			knob.SetupAppearance();
			knob.SetCamera(renderCamera);
			knob.Hide(IsHidden());

			// Create our other sprite for the 
			// empty/background portion:
			go = new GameObject();
			go.name = name + " - Empty Bar";
			go.transform.parent = transform;
			go.transform.localPosition = Vector3.zero;
			go.transform.localRotation = Quaternion.identity;
			go.transform.localScale = Vector3.one;
			go.layer = gameObject.layer;
			emptySprite = (AutoSprite) go.AddComponent(typeof(AutoSprite));
			emptySprite.plane = plane;
			emptySprite.autoResize = autoResize;
			emptySprite.pixelPerfect = pixelPerfect;
			emptySprite.persistent = persistent;
			emptySprite.ignoreClipping = ignoreClipping;
			emptySprite.bleedCompensation = bleedCompensation;
			if (!managed)
				emptySprite.renderer.sharedMaterial = renderer.sharedMaterial;
			else
			{
				if (manager != null)
				{
					emptySprite.Managed = managed;
					manager.AddSprite(emptySprite);
					emptySprite.SetDrawLayer(drawLayer);	// Knob should be drawn in front of the bar
				}
				else
					Debug.LogError("Sprite on object \"" + name + "\" not assigned to a SpriteManager!");
			}
			emptySprite.color = color;
			emptySprite.SetAnchor(anchor);
			emptySprite.Setup(width, height, m_spriteMesh.material);
			if (states[1].spriteFrames.Length != 0)
			{
				emptySprite.animations = new UVAnimation[1];
				emptySprite.animations[0] = new UVAnimation();
				emptySprite.animations[0].SetAnim(states[1], 0);
				emptySprite.PlayAnim(0, 0);
			}
			emptySprite.renderCamera = renderCamera;
			emptySprite.Hide(IsHidden());
			
			// Add our child objects as children
			// of our container:
			if(container != null)
			{
				container.AddChild(knob.gameObject);
				container.AddChild(emptySprite.gameObject);
			}

			SetState(0);

			// Force the value to update:
			m_value = -1f;
			Value = defaultValue;
		}

		// Since hiding while managed depends on
		// setting our mesh extents to 0, and the
		// foregoing code causes us to not be set
		// to 0, re-hide ourselves:
		if (managed && m_hidden)
			Hide(true);
	}
Exemplo n.º 56
0
	// Mirrors the specified sprite's settings
	public override void Mirror(SpriteRoot s)
	{
		base.Mirror(s);

		lowerLeftPixel = ((SimpleSprite)s).lowerLeftPixel;
		pixelDimensions = ((SimpleSprite)s).pixelDimensions;
	}
Exemplo n.º 57
0
	private static float GetBottom (SpriteRoot parentSprite, Vector2 percentage)
	{
		return parentSprite.height * (-percentage.y / 100) + parentSprite.height;
	}
Exemplo n.º 58
0
	// Returns true if any of the settings do not match:
	public override bool DidChange(SpriteRoot s)
	{
		if (base.DidChange(s))
			return true;
		if (((SimpleSprite)s).lowerLeftPixel != lowerLeftPixel)
			return true;
		if (((SimpleSprite)s).pixelDimensions != pixelDimensions)
			return true;

		return false;
	}
Exemplo n.º 59
0
	// Called whenever the control changes size
	protected void OnResize(float newWidth, float newHeight, SpriteRoot sprite)
	{
		UpdateCollider();
	}
Exemplo n.º 60
0
	public override void Copy(SpriteRoot s, ControlCopyFlags flags)
	{
		base.Copy(s, flags);

		if (!(s is UIProgressBar))
			return;

		if (Application.isPlaying)
		{
			UIProgressBar b = (UIProgressBar)s;


			if ((flags & ControlCopyFlags.Appearance) == ControlCopyFlags.Appearance)
			{
				if (emptySprite != null)
					emptySprite.Copy(b.emptySprite);
			}
		}
	}