Represents a Sprite object for use in 2D gameplay.

Наследование: UnityEngine.Object
Пример #1
0
        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);
        }
Пример #2
0
 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();                            
 }
 /// <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;
 }
Пример #4
0
		public Notification(string text)
		{
			this.Text = text;

			var tex = Resources.Load(GameJolt.API.Constants.DEFAULT_NOTIFICATION_ASSET_PATH) as Texture2D;
			this.Image = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(.5f, .5f), tex.width);
		}
Пример #5
0
 private void CreateSprite(Color pointColor)
 {
     Texture2D tex = new Texture2D(1, 1, TextureFormat.ARGB32, false);
     tex.SetPixel(0, 0, new Color(1.0f, 1.0f, 1.0f, 1.0f));
     tex.SetPixel(0, 0, pointColor);
     _sprite = Sprite.Create(tex, new Rect(Vector2.zero, Vector2.one), Vector2.one * 0.5f);
 }
Пример #6
0
        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;
        }
Пример #7
0
 /// <summary>
 /// 在x,y(UV)点绘制一个精灵,无论这个精灵是单独的还是多重组合的.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="sprite"></param>
 public static void DrawSprite(float x, float y, Sprite sprite)
 {
     Texture t = sprite.texture;
     Rect tr = sprite.rect;
     Rect r = new Rect(tr.x / t.width, tr.y / t.height, tr.width / t.width, tr.height / t.height);
     GUI.DrawTextureWithTexCoords(new Rect(x, y, tr.width, tr.height), t, r);
 }
Пример #8
0
        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;
        }
		/// <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");
		}
		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);

				}

			}

		}
Пример #11
0
        // Use this for initialization
        void Awake()
        {
            board = new Logic.Board();
            board.CreateAnimals();

            boardSprite = GetComponent<SpriteRenderer>().sprite;
        }
		public override void Reset() {
			
			base.Reset();
			
			this.tempSprite = null;
			
		}
        public override void Reset()
        {
            gameObject = null;
            resetOnExit = false;

            spriteToSwap = new Sprite();
        }
Пример #14
0
		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;
		}
        private void LoadExternalCoroutine(string name, UIImage image)
        {
            string url = "file://" + GameManager.Instance.mainGame.ExternalResourcePath + "/" + name + ".jpg";
            Debug.Log(name);
            WWW www = new WWW(url);

            if (string.IsNullOrEmpty(www.error))
            {
             				www.LoadImageIntoTexture(loaderTexture);

                Sprite sprite = Sprite.Create(loaderTexture,
                    new Rect(0, 0, loaderTexture.width, loaderTexture.height),
                    // new Rect(0, 0, www.texture.width, www.texture.height),  //->this eat up memory!!
                    new Vector2(0.5f, 0.5f), 100.0f);

                Sprite[] sprites = new Sprite[1];
                sprites[0] = sprite;
                image.SetSprites(sprites);
                image.Sprite = 0;

                DestroyImmediate(www.texture);

            }
            else
            {
                Debug.LogWarning(www.error);

                image.SetSprites(UIManager.LoadSprite(name));
                image.Sprite = 0;
            }

            www.Dispose();
            www = null;
        }
        public void Awake()
        {
            Instance = this;

            // Set up persistent stuff
            if (uiAtlas == null)
            {
                uiAtlas = GameDatabase.Instance.GetTexture("ContractConfigurator/ui/MissionControl", false);
                itemEnabled = UnityEngine.Sprite.Create(uiAtlas, new Rect(101, 205, 26, 50), new Vector2(13, 25), 100.0f, 0, SpriteMeshType.Tight, new Vector4(16, 6, 6, 6));
                itemDisabled = UnityEngine.Sprite.Create(uiAtlas, new Rect(101, 153, 26, 50), new Vector2(13, 25), 100.0f, 0, SpriteMeshType.Tight, new Vector4(16, 6, 6, 6));
                prestigeSprites[0] = UnityEngine.Sprite.Create(uiAtlas, new Rect(58, 223, 35, 11), new Vector2(17.5f, 5.5f));
                prestigeSprites[1] = UnityEngine.Sprite.Create(uiAtlas, new Rect(58, 234, 35, 11), new Vector2(17.5f, 5.5f));
                prestigeSprites[2] = UnityEngine.Sprite.Create(uiAtlas, new Rect(58, 245, 35, 11), new Vector2(17.5f, 5.5f));

                // Set up item status image state array
                itemStatusStates[0] = new UIStateImage.ImageState();
                itemStatusStates[1] = new UIStateImage.ImageState();
                itemStatusStates[2] = new UIStateImage.ImageState();
                itemStatusStates[3] = new UIStateImage.ImageState();
                itemStatusStates[0].name = "Offered";
                itemStatusStates[1].name = "Active";
                itemStatusStates[2].name = "Completed";
                itemStatusStates[3].name = "Unavailable";
                itemStatusStates[0].sprite = UnityEngine.Sprite.Create(uiAtlas, new Rect(118, 20, 1, 1), new Vector2(0.5f, 0.5f));
                itemStatusStates[1].sprite = UnityEngine.Sprite.Create(uiAtlas, new Rect(118, 20, 10, 10), new Vector2(5f, 5f));
                itemStatusStates[2].sprite = UnityEngine.Sprite.Create(uiAtlas, new Rect(118, 10, 10, 10), new Vector2(5f, 5f));
                itemStatusStates[3].sprite = UnityEngine.Sprite.Create(uiAtlas, new Rect(118, 0, 10, 10), new Vector2(5f, 5f));

                // Set up group status image state array
                groupExpandedActive = UnityEngine.Sprite.Create(uiAtlas, new Rect(0, 156, 97, 52), new Vector2(78f, 25f), 100.0f, 0, SpriteMeshType.Tight, new Vector4(81, 6, 6, 6));
                groupExpandedInactive = UnityEngine.Sprite.Create(uiAtlas, new Rect(0, 104, 97, 52), new Vector2(78f, 25f), 100.0f, 0, SpriteMeshType.Tight, new Vector4(81, 6, 6, 6));
                groupUnexpandedActive = UnityEngine.Sprite.Create(uiAtlas, new Rect(0, 52, 97, 52), new Vector2(78f, 25f), 100.0f, 0, SpriteMeshType.Tight, new Vector4(81, 6, 6, 6));
                groupUnexpandedInactive = UnityEngine.Sprite.Create(uiAtlas, new Rect(0, 0, 97, 52), new Vector2(78f, 25f), 100.0f, 0, SpriteMeshType.Tight, new Vector4(81, 6, 6, 6));
            }
        }
Пример #17
0
		public void DownloadImage(Action<bool> callback = null)
		{
			if (!string.IsNullOrEmpty(ImageURL))
			{
				Misc.DownloadImage(ImageURL, (Sprite image) => {
					if (image != null)
					{
						Image = image;
					}
					else
					{
						var tex = Resources.Load(GameJolt.API.Constants.DEFAULT_TROPHY_ASSET_PATH) as Texture2D;
						Image = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(.5f, .5f), tex.width);
					}
					
					if (callback != null)
					{
						callback(image != null);
					}
				});
			}
			else
			{
				if (callback != null)
				{
					callback(false);
				}
			}
		}
Пример #18
0
 /**
  * Sets the image sprite
  */
 public void SetImage(Sprite sprite)
 {
     if(this.image != null)
     {
         this.image.sprite = sprite;
     }
 }
Пример #19
0
 /*		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;
 }
Пример #20
0
        /// <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 ();
        }
Пример #21
0
		public ISQuality()
		{
			_name = "";
			_icon = new Sprite();
			GUIUtility.keyboardControl = 0;
			
		}
Пример #22
0
 public void ShowSystemMessage(string messageText, Sprite messageImage)
 {
     Show();
     systemMessageText.text = messageText;
     systemMessageImage.sprite = messageImage;
     currentTimer += systemMessageTimer;
 }
Пример #23
0
 public void addSprite(string path, Sprite sprite)
 {
     SerialObject obj = new SerialObject();
     obj.m_sprite = sprite;
     obj.m_path = path;
     m_objList.Add(obj);
 }
Пример #24
0
 public ComboBoxItem(string caption, Sprite image, bool disabled, Action onSelect)
 {
     _caption = caption;
     _image = image;
     _isDisabled = disabled;
     OnSelect = onSelect;
 }
Пример #25
0
 public BlueprintObject(string name, Sprite sprite, float x_location, float y_location)
 {
     this.name = name;
     this.sprite = sprite;
     x = x_location;
     y = y_location;
 }
 public DebugVisualVoxel(Vector3 pos, double elementSize)
 {
     size = (float)elementSize;
     size *= 0.5f;
     gameObject = new GameObject();
     gameObject.transform.position = pos;
     gameObject.transform.localScale = Vector3.one * size;
     if(sprite == null)
     {
         sprite = UnityEngine.Sprite.Create(GameDatabase.Instance.GetTexture("FerramAerospaceResearch/Textures/sprite_debug_voxel", false), new Rect(0, 0, 16, 16), new Vector2(0.5f, 0.5f), 4);
     }
     /*if (mesh == null)
     {
         Points = new List<Vector3>();
         Points.Add(new Vector3(-size, size, -size));
         Points.Add(new Vector3(size, size, -size));
         Points.Add(new Vector3(size, -size, -size));
         Points.Add(new Vector3(-size, -size, -size));
         Points.Add(new Vector3(size, size, size));
         Points.Add(new Vector3(-size, size, size));
         Points.Add(new Vector3(-size, -size, size));
         Points.Add(new Vector3(size, -size, size));
         Verts = new List<Vector3>();
         Tris = new List<int>();
         UVs = new List<Vector2>();
     }*/
     InitVoxel();
 }
Пример #27
0
		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;
		}
Пример #28
0
        // 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);
        }
Пример #29
0
        private void CreateMoochiSpots()
        {
            var d = Sprite.Create(LevelTex,
                new Rect(DifferenceRect.x, DifferenceRect.y, DifferenceRect.width, DifferenceRect.height),
                new Vector2(0.5f, 0.5f), 128);

            var dTex = d.Crop();

            Debug.Log("Fake: " + dTex.width + " " + dTex.height);

            for (var y = 0; y < dTex.height; ++y)
            {
                for (var x = 0; x < dTex.width ; ++x)
                {
                    var c = dTex.GetPixel(x, y);
                    if (c.r < 0.9f || c.g > 0.1f || c.b > 0.1f || c.a < 1f)
                        continue;
                    var bounds = FloodFill.floodFill(dTex, Color.blue, new Vector2(x, y));
                    if (!bounds.Equals(new Rect()))
                        SpotFrames.Add(bounds);
                }
            }

            Debug.Log(SpotFrames.Count);

            dTex.Apply();

            spriteTex = dTex;

            sprite = Sprite.Create(dTex,
                new Rect(0, 0, dTex.width, dTex.height),
                new Vector2(0.5f, 0.5f),128);

            if (ShowDifferences) Replace.sprite = sprite;
        }
Пример #30
0
 public void AddWeapon(string name, int atk, Sprite sprite)
 {
     Name = name;
     Atk = atk;
     SpriteWeapon = sprite;
     _listWeapons.Add (this);
 }
Пример #31
0
    /// <summary>
    /// Convenience function that changes the sprite.
    /// </summary>

    protected void SetSprite(UnityEngine.Sprite sp)
    {
        if (sp != null && mSprite2D != null && mSprite2D.sprite2D != sp)
        {
            mSprite2D.sprite2D = sp;
            if (pixelSnap)
            {
                mSprite2D.MakePixelPerfect();
            }
        }
    }
Пример #32
0
    public override void UpdateProperties()
    {
        base.UpdateProperties();
        spriteRender = (SpriteRenderer)GetComponent <SpriteRenderer>();
        sprite       = spriteRender.sprite;
        var rect = sprite.rect;

        width         = rect.width;
        height        = rect.height;
        textureName   = sprite.name;
        textureOffset = sprite.textureRectOffset;
    }
Пример #33
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Sprite o;
         o = new UnityEngine.Sprite();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #34
0
 static public int GetPhysicsShapeCount(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         var ret = self.GetPhysicsShapeCount();
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #35
0
 static public int get_border(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.border);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #36
0
 static public int get_packingRotation(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         pushValue(l, true);
         pushEnum(l, (int)self.packingRotation);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #37
0
 static public int get_textureRectOffset(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.textureRectOffset);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int get_associatedAlphaSplitTexture(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.associatedAlphaSplitTexture);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #39
0
 static public int get_packingRotation(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         pushEnum(l, (int)self.packingRotation);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #40
0
 static public int get_border(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         pushValue(l, self.border);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #41
0
 public SNProjectile(float projSpeed, float projSize, Sprite projSprite,
                     SpellNode timeoutSpell = null, float timeoutTime = 0,
                     SpellNode contactSpell = null,
                     SpellNode trailSpell   = null, float trailDelay = 0) : base(timeoutSpell, timeoutTime)
 {
     this.projSpeed    = projSpeed;
     this.projSize     = projSize;
     this.projSprite   = projSprite;
     this.contactSpell = contactSpell;
     this.trailSpell   = trailSpell;
     this.trailDelay   = trailDelay;
 }
Пример #42
0
    /// <summary>
    /// Update the sprite in case it was animated.
    /// </summary>

    public override void Update()
    {
        if (nextSprite != null)
        {
            if (nextSprite != mSprite)
            {
                sprite2D = nextSprite;
            }
            nextSprite = null;
        }
        base.Update();
    }
Пример #43
0
        protected override void Awake()
        {
            _image = GetComponent <Image>();
            _tabs  = GetComponentInParent <TabControl>();

            if (_active == null)
            {
                _active = spriteState.highlightedSprite;
            }

            onClick.AddListener(OnClick);
        }
Пример #44
0
    /// <summary>
    /// Update the sprite in case it was animated.
    /// </summary>

    protected override void OnUpdate()
    {
        if (nextSprite != null)
        {
            if (nextSprite != mSprite)
            {
                sprite2D = nextSprite;
            }
            nextSprite = null;
        }
        base.OnUpdate();
    }
Пример #45
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.Sprite o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.Sprite();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Пример #46
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.Sprite o;
         o = new UnityEngine.Sprite();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Пример #47
0
 static public int OverridePhysicsShape(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         System.Collections.Generic.IList <UnityEngine.Vector2[]> a1;
         checkType(l, 2, out a1);
         self.OverridePhysicsShape(a1);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #48
0
    void Start()
    {
        rOnes = GameObject.Find("EnhancedTextHandler/Ones").GetComponent <SpriteRenderer>();
        rTens = GameObject.Find("EnhancedTextHandler/Tens").GetComponent <SpriteRenderer>();
        rHuns = GameObject.Find("EnhancedTextHandler/Hundreds").GetComponent <SpriteRenderer>();

        rOnes.transform.position = new Vector3(rOnes.transform.localScale.x * 2.1f, Camera.main.orthographicSize - (rOnes.transform.localScale.y * 2), 0);
        rTens.transform.position = new Vector3(0, Camera.main.orthographicSize - (rOnes.transform.localScale.y * 2), 0);
        rHuns.transform.position = new Vector3(-rOnes.transform.localScale.x * 2.1f, Camera.main.orthographicSize - (rOnes.transform.localScale.y * 2), 0);

        ones = Resources.Load <UnityEngine.Sprite> ("Pong/Numbers/1black");
        initStrings("white");
    }
    static void Sprite_uv(JSVCall vc)
    {
        UnityEngine.Sprite _this = (UnityEngine.Sprite)vc.csObj;
        var result = _this.uv;
        var arrRet = result;

        for (int i = 0; arrRet != null && i < arrRet.Length; i++)
        {
            JSApi.setVector2S((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
            JSApi.moveSaveID2Arr(i);
        }
        JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
    }
Пример #50
0
        /**
         * <summary>Links the UI GameObjects to the class, based on the supplied uiButtonID.</summary>
         * <param name = "canvas">The Canvas that contains the UI GameObjects</param>
         * <param name = "linkUIGraphic">What Image component the Element's Graphics should be linked to (ImageComponent, ButtonTargetGraphic)</param>
         * <param name = "emptySlotTexture">If set, the texture to use when a slot is considered empty</param>
         */
        public void LinkUIElements(Canvas canvas, LinkUIGraphic linkUIGraphic, Texture2D emptySlotTexture = null)
        {
            if (canvas != null)
            {
                uiButton = Serializer.GetGameObjectComponent <UnityEngine.UI.Button> (uiButtonID, canvas.gameObject);
            }
            else
            {
                uiButton = null;
            }

            if (uiButton)
            {
                                #if TextMeshProIsPresent
                uiText = uiButton.GetComponentInChildren <TMPro.TextMeshProUGUI>();
                                #else
                uiText = uiButton.GetComponentInChildren <Text>();
                                #endif
                uiRawImage = uiButton.GetComponentInChildren <RawImage>();

                if (linkUIGraphic == LinkUIGraphic.ImageComponent)
                {
                    uiImage = uiButton.GetComponentInChildren <Image>();
                }
                else if (linkUIGraphic == LinkUIGraphic.ButtonTargetGraphic)
                {
                    if (uiButton.targetGraphic != null)
                    {
                        if (uiButton.targetGraphic is Image)
                        {
                            uiImage = uiButton.targetGraphic as Image;
                        }
                        else
                        {
                            ACDebug.LogWarning("Cannot assign UI Image for " + uiButton.name + "'s target graphic as " + uiButton.targetGraphic + " is not an Image component.", canvas);
                        }
                    }
                    else
                    {
                        ACDebug.LogWarning("Cannot assign UI Image for " + uiButton.name + "'s target graphic because it has none.", canvas);
                    }
                }

                originalColour = uiButton.colors.normalColor;
            }

            if (emptySlotTexture != null)
            {
                emptySprite = Sprite.Create(emptySlotTexture, new Rect(0f, 0f, emptySlotTexture.width, emptySlotTexture.height), new Vector2(0.5f, 0.5f), 100f, 0, SpriteMeshType.FullRect);
            }
        }
Пример #51
0
    /// <summary>
    /// Cache the sprite we'll be working with.
    /// </summary>

    protected override void OnInit()
    {
        base.OnInit();
        mSprite   = (mWidget as UISprite);
        mSprite2D = (mWidget as UI2DSprite);
        if (mSprite != null)
        {
            mNormalSprite = mSprite.spriteName;
        }
        if (mSprite2D != null)
        {
            mNormalSprite2D = mSprite2D.sprite2D;
        }
    }
Пример #52
0
 static public int GetPhysicsShapePointCount(IntPtr l)
 {
     try {
         UnityEngine.Sprite self = (UnityEngine.Sprite)checkSelf(l);
         System.Int32       a1;
         checkType(l, 2, out a1);
         var ret = self.GetPhysicsShapePointCount(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #53
0
 public void OnDrop(PointerEventData data)
 {
     this.containerImage.color = this.normalColor;
     if ((Object)this.receivingImage == (Object)null)
     {
         return;
     }
     UnityEngine.Sprite dropSprite = this.GetDropSprite(data);
     if (!((Object)dropSprite != (Object)null))
     {
         return;
     }
     this.receivingImage.overrideSprite = dropSprite;
 }
Пример #54
0
    /// <summary>
    /// UnityEngine.Sprite drawn by this widget.
    /// </summary>

    virtual public void FastSetSprite(UnityEngine.Sprite spr)
    {
        if (mSprite != null)
        {
            mSprite    = spr;
            nextSprite = null;
            //enabled = true;
        }
        else
        {
            sprite2D = spr;
            //enabled = true;
        }
    }
Пример #55
0
        void DoSetImageSourceValue()
        {
            if (_image == null)
            {
                return;
            }

            if (resetOnExit.Value)
            {
                _originalSprite = _image.sprite;
            }

            _image.sprite = (UnityEngine.Sprite)sprite.Value;
        }
Пример #56
0
    public Mesh Get(SpriteRenderer spriteRenderer, Vector2 size, Vector2 uv0, Vector2 uv1)
    {
        Rect    uvRect = new Rect();
        Vector2 scale  = Vector2.one;

        UnityEngine.Sprite sprite = spriteRenderer.sprite;
        if (spriteRenderer == null || sprite == null || sprite.texture == null)
        {
            return(null);
        }

        Rect spriteRect = sprite.textureRect;

        uvRect.x      = spriteRect.x / sprite.texture.width;
        uvRect.y      = spriteRect.y / sprite.texture.height;
        uvRect.width  = spriteRect.width / sprite.texture.width;
        uvRect.height = spriteRect.height / sprite.texture.height;

        // Vertex Position Calculation
        scale.x = (float)sprite.texture.width / spriteRect.width;
        scale.y = (float)sprite.texture.height / spriteRect.height;

        size.x /= scale.x;
        size.y /= scale.y;

        size.x *= (float)sprite.texture.width / (sprite.pixelsPerUnit * 2);
        size.y *= (float)sprite.texture.height / (sprite.pixelsPerUnit * 2);

        mesh.vertices  = new Vector3[] { new Vector3(-size.x, -size.y), new Vector3(size.x, -size.y), new Vector3(size.x, size.y), new Vector3(-size.x, size.y) };
        mesh.triangles = new int[] { 0, 1, 2, 2, 3, 0 };

        Vector2[] meshUV = new Vector2[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1) };

        meshUV[0].x = uvRect.x + uvRect.width * uv0.x;
        meshUV[0].y = uvRect.y + uvRect.height * uv0.y;

        meshUV[1].x = uvRect.x + uvRect.width * uv1.x;
        meshUV[1].y = uvRect.y + uvRect.height * uv0.y;;

        meshUV[2].x = uvRect.x + uvRect.width * uv1.x;
        meshUV[2].y = uvRect.y + uvRect.height * uv1.y;

        meshUV[3].x = uvRect.x + uvRect.width * uv0.x;;
        meshUV[3].y = uvRect.y + uvRect.height * uv1.y;

        mesh.uv = meshUV;

        return(mesh);
    }
Пример #57
0
        private UnityEngine.Sprite[] remove(UnityEngine.Sprite[] arr, int removePt)
        {
            UnityEngine.Sprite[] newArr = new UnityEngine.Sprite[arr.Length - 1];
            int k = 0;

            for (int i = 0; i < arr.Length; i++)
            {
                if (i != removePt)
                {
                    newArr[k] = arr[i];
                    k++;
                }
            }
            return(newArr);
        }
Пример #58
0
        public static Minimap.MinimapIcon Create(RectTransform parent, GameObject trackedObject, Minimap.IconStyle style)
        {
            UnityEngine.Sprite spriteForStyle = Minimap.GetSpriteForStyle(style);
            GameObject         uiElement      = new GameObject("MinimapIcon");
            RectTransform      transform      = uiElement.AddComponent <RectTransform>();

            transform.anchorMin = transform.anchorMax = new Vector3(0.5f, 0.5f);
            transform.sizeDelta = new Vector2((float)spriteForStyle.texture.width, (float)spriteForStyle.texture.height);
            Image image = uiElement.AddComponent <Image>();

            image.sprite = spriteForStyle;
            image.type   = Image.Type.Simple;
            uiElement.transform.SetParent(parent, false);
            return(new Minimap.MinimapIcon(trackedObject, uiElement, style));
        }
// fields

// properties
    static void SpriteRenderer_sprite(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.SpriteRenderer _this = (UnityEngine.SpriteRenderer)vc.csObj;
            var result = _this.sprite;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Sprite         arg0  = (UnityEngine.Sprite)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.SpriteRenderer _this = (UnityEngine.SpriteRenderer)vc.csObj;
            _this.sprite = arg0;
        }
    }
Пример #60
0
 static public int OverrideGeometry(IntPtr l)
 {
     try {
         UnityEngine.Sprite    self = (UnityEngine.Sprite)checkSelf(l);
         UnityEngine.Vector2[] a1;
         checkType(l, 2, out a1);
         System.UInt16[] a2;
         checkType(l, 3, out a2);
         self.OverrideGeometry(a1, a2);
         return(0);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }