• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnityEngine.Sprite类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Button

        public Button(DisplayObject upState, string text ="", DisplayObject downState=null, TextFormat format=null)
        {
            //if (upState == null) throw new ErrorEvent("Texture cannot be null");

            mParent = upState.parent;
            mUpState = upState;
            mDownState = downState != null ? downState : upState;
            mBackground = upState;
            mTextFormat = format;

            mScaleWhenDown = 0.9f;
            mAlphaWhenDisabled = 0.5f;
            mEnabled = true;
            mIsDown = false;
            mUseHandCursor = true;
            mTextBounds = new Rectangle(0, 0, upState.width, upState.height);

            mContents = new Sprite();
            mContents.addChild(mBackground);
            addChild(mContents);

            //addEventListener(TouchEvent.TOUCH, onTouch);
            addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

            if (text.Length > 0) this.text = text;

            this.x = upState.x;
            this.y = upState.y;
            upState.x = upState.y = 0;

            if(mParent != null)
                (mParent as MovieClip).addChild(this);
        }
开发者ID:crl,项目名称:UniStarling,代码行数:33,代码来源:Button.cs


示例2: DrawSprite

        // Draw the specified Image.
        public static void DrawSprite(Sprite sprite, Rect drawArea, Color color)
        {
            if (sprite == null)
                return;

            Texture2D tex = sprite.texture;
            if (tex == null)
                return;

            Rect outer = sprite.rect;
            Rect inner = outer;
            inner.xMin += sprite.border.x;
            inner.yMin += sprite.border.y;
            inner.xMax -= sprite.border.z;
            inner.yMax -= sprite.border.w;

            Vector4 uv4 = UnityEngine.Sprites.DataUtility.GetOuterUV(sprite);
            Rect uv = new Rect(uv4.x, uv4.y, uv4.z - uv4.x, uv4.w - uv4.y);
            Vector4 padding = UnityEngine.Sprites.DataUtility.GetPadding(sprite);
            padding.x /= outer.width;
            padding.y /= outer.height;
            padding.z /= outer.width;
            padding.w /= outer.height;

            DrawSprite(tex, drawArea, padding, outer, inner, uv, color, null);
        }
开发者ID:gdzzzyyy,项目名称:UGUIlok,代码行数:27,代码来源:SpriteDrawUtility.cs


示例3: BackgroundScript

 /// <summary>
 /// 주어진 정보를 이용하여 BackgroundScript 인스턴스를 초기화합니다.
 /// </summary>
 /// <param name="spriteToUse">사용할 Sprite 파일을 가리킵니다.</param>
 /// <param name="isWrappingUI">이 스크립트가 현재 UI를 덮어서 적용되는 것인지 결정합니다.</param>
 public BackgroundScript(Sprite spriteToUse, bool isWrappingUI)
 {
     base.ScriptCode = (int)ScriptTypeCode.BackgroundScript;
     base.IsStepScript = false;
     this.BackgroundSprite = spriteToUse;
     this.IsWrappingUI = isWrappingUI;
 }
开发者ID:watermelonbar,项目名称:ProjectAILibrary,代码行数:12,代码来源:BackgroundScript.cs


示例4: BlueprintObject

 public BlueprintObject(string name, Sprite sprite, float x_location, float y_location)
 {
     this.name = name;
     this.sprite = sprite;
     x = x_location;
     y = y_location;
 }
开发者ID:jee7,项目名称:BuildingGenerator2D,代码行数:7,代码来源:BlueprintObject.cs


示例5: Create

		public static pb_GUIStyle Create(
			Color color,
			Color? normalColor = null,
			Color? highlightedColor = null,
			Color? pressedColor = null,
			Color? disabledColor = null,
			Texture2D image = null,
			Sprite sprite = null,
			Font font = null,
					Color? fontColor = null)
		{
			pb_GUIStyle style = ScriptableObject.CreateInstance<pb_GUIStyle>();

			style.color				= color;
			style.image 			= image;
			style.sprite 			= sprite;
			style.font				= font;
			
			if(normalColor != null) 	style.normalColor		= (Color) normalColor;
			if(highlightedColor != null) style.highlightedColor	= (Color) highlightedColor;
			if(pressedColor != null) 	style.pressedColor		= (Color) pressedColor;
			if(disabledColor != null) 	style.disabledColor 		= (Color) disabledColor;
			if(fontColor != null) 		style.fontColor 			= (Color) fontColor;

			return style;
		}
开发者ID:procore3d,项目名称:giles,代码行数:26,代码来源:pb_GUIStyle.cs


示例6: CreateTexture

        private Texture2D CreateTexture(Sprite sprite)
        {
            if (!sprite)
            {
                return null;
            }
            Texture2D texture = null;
            try
            {
                texture = SetupTexture(sprite);
            }
            catch
            {
                string path = AssetDatabase.GetAssetPath(sprite);
                TextureImporter importer = (TextureImporter)AssetImporter.GetAtPath(path);
                importer.isReadable = true;
                AssetDatabase.ImportAsset(path);

                try
                {
                    texture = SetupTexture(sprite);
                }
                catch
                {
                    Debug.LogError("Texture error!");
                }

            }
            return texture;
        }
开发者ID:LawsonLamb,项目名称:out_foxed,代码行数:30,代码来源:TileData.cs


示例7: CreateSpriteMesh

		public static SpriteMesh CreateSpriteMesh(Sprite sprite)
		{
			SpriteMesh spriteMesh = SpriteMeshPostprocessor.GetSpriteMeshFromSprite(sprite);
			SpriteMeshData spriteMeshData = null;
			
			if(!spriteMesh && sprite)
			{
				string spritePath = AssetDatabase.GetAssetPath(sprite);
				string directory = Path.GetDirectoryName(spritePath);
				string assetPath = AssetDatabase.GenerateUniqueAssetPath(directory + Path.DirectorySeparatorChar + sprite.name + ".asset");
				
				spriteMesh = ScriptableObject.CreateInstance<SpriteMesh>();
				InitFromSprite(spriteMesh,sprite);
				AssetDatabase.CreateAsset(spriteMesh,assetPath);
				
				spriteMeshData = ScriptableObject.CreateInstance<SpriteMeshData>();
				spriteMeshData.name = spriteMesh.name + "_Data";
				spriteMeshData.hideFlags = HideFlags.HideInHierarchy;
				InitFromSprite(spriteMeshData,sprite);
				AssetDatabase.AddObjectToAsset(spriteMeshData,assetPath);
				
				UpdateAssets(spriteMesh,spriteMeshData);
				
				AssetDatabase.SaveAssets();
				AssetDatabase.ImportAsset(assetPath);
				
				Selection.activeObject = spriteMesh;
			}
			
			return spriteMesh;
		}
开发者ID:Kundara,项目名称:project1,代码行数:31,代码来源:SpriteMeshUtils.cs


示例8: Load

		/// <summary>
		/// エディタ上に保存してあるデータをロード
		/// </summary>
		void Load()
		{
			gameScreenWidth = UtageEditorPrefs.LoadInt(UtageEditorPrefs.Key.GameScreenWidth, 800);
			gameScreenHeight = UtageEditorPrefs.LoadInt(UtageEditorPrefs.Key.GameScreenHegiht, 600);
			font = UtageEditorPrefs.LoadAsset<FontData>(UtageEditorPrefs.Key.CreateAdvEngineWindowFont,
				"Assets/Utage/Examples/ScriptableObject/Example FontData.asset");
			clickSe = UtageEditorPrefs.LoadAsset<AudioClip>(UtageEditorPrefs.Key.CreateAdvEngineWindowClickSe,
				"Assets/Utage/Examples/Audio/mouse_click.wav");

			transitionFadeBg = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowTransitionFadeBg,
				"Assets/Utage/Examples/Textures/UI/transitionFadeBg.png");

			msgWindowSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowMsgWindowSprite,
				"Assets/Utage/Examples/Textures/UI/MessageWindow.png");
			isEnableCloseButton = UtageEditorPrefs.LoadBool(UtageEditorPrefs.Key.CreateAdvEngineWindowIsEnableCloseButton, true);
			closeButtonSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowCloseButtonSprite,
				"Assets/Utage/Examples/Textures/UI/CloseIcon.png");

			selectionItemPrefab = UtageEditorPrefs.LoadPrefab<AdvUiSelection>(UtageEditorPrefs.Key.CreateAdvEngineWindowSelectionItemPrefab,
				"Assets/Utage/Examples/Prefabs/SelectionItem.prefab");

			isEnableBackLog = UtageEditorPrefs.LoadBool(UtageEditorPrefs.Key.CreateAdvEngineWindowIsEnableCloseButton,true);
			backLogButtonSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogButtonSprite,
				"Assets/Utage/Examples/Textures/UI/SystemButtonSS.png");
			backLogFilterSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogFilterSprite,
				"Assets/Utage/Examples/Textures/UI/filterBg.png");
			backLogScrollUpArrow = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogScrollUpArrow,
				"Assets/Utage/Examples/Textures/UI/AllowUp.png");
			backLogItemPrefab = UtageEditorPrefs.LoadPrefab<AdvUiBacklog>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogItemPrefab,
				"Assets/Utage/Examples/Prefabs/BacklogItem.prefab");
			backLogCloseButtonSprite = UtageEditorPrefs.LoadAsset<Sprite>(UtageEditorPrefs.Key.CreateAdvEngineWindowBackLogCloseButtonSprite,
				"Assets/Utage/Examples/Textures/UI/SystemButtonSS.png");
		}
开发者ID:OsamaRazaAnsari,项目名称:2DDressUpGame,代码行数:36,代码来源:CreateAdvEngineWindow.cs


示例9: Awake

        // Use this for initialization
        void Awake()
        {
            board = new Logic.Board();
            board.CreateAnimals();

            boardSprite = GetComponent<SpriteRenderer>().sprite;
        }
开发者ID:Pavelko007,项目名称:AnimalChess,代码行数:8,代码来源:Board.cs


示例10: Reset

		public override void Reset() {
			
			base.Reset();
			
			this.tempSprite = null;
			
		}
开发者ID:Cyberbanan,项目名称:Unity3d.UI.Windows,代码行数:7,代码来源:SpriteResourceItem.cs


示例11: Validate

		public override void Validate(Object item) {

			base.Validate(item);

			if (item == null) {
				
				if (this.tempSprite != null) {
					
					item = this.tempSprite;
					
				}
				
				if (item == null) return;
				
			}
			
			this.tempSprite = item as Sprite;
			
			if (this.tempSprite != null) {

				var imp = UnityEditor.TextureImporter.GetAtPath(this.assetPath) as UnityEditor.TextureImporter;
				this.multiObjects = false;
				if (imp.spriteImportMode == UnityEditor.SpriteImportMode.Multiple) {

					var allObjects = Resources.LoadAll(this.resourcesPath);
					this.multiObjects = true;
					this.objectIndex = System.Array.IndexOf(allObjects, item);

				}

			}

		}
开发者ID:Cyberbanan,项目名称:Unity3d.UI.Windows,代码行数:33,代码来源:SpriteResourceItem.cs


示例12: AddWeapon

 public void AddWeapon(string name, int atk, Sprite sprite)
 {
     Name = name;
     Atk = atk;
     SpriteWeapon = sprite;
     _listWeapons.Add (this);
 }
开发者ID:Eleart,项目名称:SimpleQuest,代码行数:7,代码来源:Weapon.cs


示例13: AssignValues

        public Text txtName; //Used to Store and Display Name from the server

        #endregion Fields

        #region Methods

        public void AssignValues(string fId, string picUrl, string txtName, Sprite imgPic)
        {
            this.fId = fId;
            this.picUrl = picUrl;
            this.txtName.text = txtName;
            this.imgPic.sprite = imgPic;
        }
开发者ID:amisiak7,项目名称:jewels2,代码行数:13,代码来源:ListItemGift.cs


示例14: GenerateBall

 public void GenerateBall(int number, Vector3 position, Sprite mySprite){            
     text = transform.GetChild(0).GetComponent<Text>();        
     GetComponent<Image>().sprite = mySprite;
     GetComponent<RectTransform>().anchoredPosition = position;        
     ballNumber = number;        
     text.text = number.ToString();                            
 }
开发者ID:loloop,项目名称:totem-master,代码行数:7,代码来源:BallGameButton.cs


示例15: addSprite

 public void addSprite(string path, Sprite sprite)
 {
     SerialObject obj = new SerialObject();
     obj.m_sprite = sprite;
     obj.m_path = path;
     m_objList.Add(obj);
 }
开发者ID:zhutaorun,项目名称:unitygame,代码行数:7,代码来源:SOSpriteList.cs


示例16: Open

        /// <summary>
        /// Open the MessageBox
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="text">Text.</param>
        /// <param name="icon">Icon.</param>
        /// <param name="result">Result.</param>
        /// <param name="buttons">Buttons.</param>
        public virtual void Open(string title, string text, Sprite icon, UnityAction<string> result, params string[] buttons)
        {
            for (int i=0; i<buttonCache.Count; i++) {
                buttonCache[i].gameObject.SetActive(false);
            }
            if (!string.IsNullOrEmpty (title)) {
                this.title.text = title;
                this.title.gameObject.SetActive (true);
            } else {
                this.title.gameObject.SetActive(false);
            }

            this.text.text = text;

            if(icon != null){
                this.icon.sprite = icon;
                this.icon.transform.parent.gameObject.SetActive(true);
            }else{
                this.icon.transform.parent.gameObject.SetActive(false);
            }
            button.gameObject.SetActive (false);
            for (int i=0; i<buttons.Length; i++) {
                string caption=buttons[i];
                AddButton(caption).onClick.AddListener(delegate() {
                    result.Invoke(caption);
                    Close();
                });
            }
            base.Open ();
        }
开发者ID:gloowa,项目名称:mstest,代码行数:38,代码来源:MessageBox.cs


示例17: ShowSystemMessage

 public void ShowSystemMessage(string messageText, Sprite messageImage)
 {
     Show();
     systemMessageText.text = messageText;
     systemMessageImage.sprite = messageImage;
     currentTimer += systemMessageTimer;
 }
开发者ID:mengtest,项目名称:2DRPG,代码行数:7,代码来源:SystemMessagesScreen.cs


示例18: setAction

 /*		Action (string actionName, Sprite actionSprite, ActionType actionType) {
     Name = actionName;
     Sprite = actionSprite;
     Type = actionType;
     Enabled = true;
 }*/
 public void setAction(string actionName, Sprite actionSprite, ActionType actionType)
 {
     Name = actionName;
     Sprite = actionSprite;
     Type = actionType;
     Enabled = true;
 }
开发者ID:sentonnes,项目名称:RTS-Framework,代码行数:13,代码来源:Action.cs


示例19: ComboBoxItem

 public ComboBoxItem(string caption, Sprite image, bool disabled, Action onSelect)
 {
     _caption = caption;
     _image = image;
     _isDisabled = disabled;
     OnSelect = onSelect;
 }
开发者ID:parkersprouse,项目名称:Spectrum,代码行数:7,代码来源:ComboBoxItem.cs


示例20: SetImage

 /**
  * Sets the image sprite
  */
 public void SetImage(Sprite sprite)
 {
     if(this.image != null)
     {
         this.image.sprite = sprite;
     }
 }
开发者ID:Putaitu,项目名称:unity-boilerplate,代码行数:10,代码来源:UIQuestNotifier.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.SpriteRenderer类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.SphereCollider类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap