当前位置: 首页>>代码示例>>C#>>正文


C# SpriteRoot类代码示例

本文整理汇总了C#中SpriteRoot的典型用法代码示例。如果您正苦于以下问题:C# SpriteRoot类的具体用法?C# SpriteRoot怎么用?C# SpriteRoot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SpriteRoot类属于命名空间,在下文中一共展示了SpriteRoot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

	// 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
	}
开发者ID:ftcaicai,项目名称:ArkClient,代码行数:11,代码来源:AsScreenSizeSetter.cs

示例2: Copy

	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;
		}
	}
开发者ID:jordan1818,项目名称:JumpsterProject,代码行数:14,代码来源:UIBtnWWW.cs

示例3: Copy

	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;
		}
	}
开发者ID:jordan1818,项目名称:JumpsterProject,代码行数:15,代码来源:UIBtnLoadScene.cs

示例4: Copy

    /// <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);
    }
开发者ID:rogeryuan99,项目名称:Hello,代码行数:24,代码来源:SimpleSprite.cs

示例5: GetPositionFromParentSprite

	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;
	}
开发者ID:adahera222,项目名称:properme,代码行数:41,代码来源:EZGUIExtensions.cs

示例6: OnResize

	// Called whenever the control changes size
	protected void OnResize(float newWidth, float newHeight, SpriteRoot sprite)
	{
		UpdateCollider();
	}
开发者ID:juliancruz87,项目名称:transpp,代码行数:5,代码来源:AutoSpriteControlBase.cs

示例7: GetBottom

	private static float GetBottom (SpriteRoot parentSprite, Vector2 percentage)
	{
		return parentSprite.height * (-percentage.y / 100) + parentSprite.height;
	}
开发者ID:adahera222,项目名称:properme,代码行数:4,代码来源:EZGUIExtensions.cs

示例8: Start

	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];
//.........这里部分代码省略.........
开发者ID:nbolabs,项目名称:KnifeLi,代码行数:101,代码来源:UISlider.cs

示例9: Copy

	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;
		}
	}
开发者ID:juliancruz87,项目名称:transpp,代码行数:35,代码来源:UIStateToggleBtn.cs

示例10: CopyAll

	/// <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;
	}
开发者ID:amutnick,项目名称:CrackTheCode_Repo,代码行数:35,代码来源:AutoSpriteBase.cs

示例11: Copy

	/// <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();
	}
开发者ID:uptopgames,项目名称:rhythm,代码行数:41,代码来源:PackedSprite.cs

示例12: Start

	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);

//.........这里部分代码省略.........
开发者ID:uptopgames,项目名称:rhythm,代码行数:101,代码来源:UIProgressBar.cs

示例13: Copy

	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);
			}
		}
	}
开发者ID:uptopgames,项目名称:rhythm,代码行数:19,代码来源:UIProgressBar.cs

示例14: Start

	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);
	}
开发者ID:MtvnGames,项目名称:marblemadness,代码行数:100,代码来源:UIRadioBtn.cs

示例15: Copy

	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;
		}
	}
开发者ID:MtvnGames,项目名称:marblemadness,代码行数:36,代码来源:UIRadioBtn.cs


注:本文中的SpriteRoot类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。