Example #1
0
    public static SpriteSelector Create_FixedSize(float width, float height)
    {
        SpriteSelector created = new SpriteSelector();

        created.layoutMode = LayoutMode.FixedSize;
        created.width      = width;
        created.height     = height;
        return(created);
    }
Example #2
0
    public static SpriteSelector Create_ScaleByWidth()
    {
        SpriteSelector created = new SpriteSelector();

        created.layoutMode  = LayoutMode.ScaleByWidth;
        created.widthRatio  = 16;
        created.heightRatio = 9;
        return(created);
    }
Example #3
0
        public override void Draw(LocalizationObjectItem drawing, LocalizationObjectItem reference = null, params GUILayoutOption[] areaOptions)
        {
            EditableLabel_Auto currentLabel;
            SpriteSelector     currentSelector;

            if (labelDict == null)
            {
                labelDict = new Dictionary <int, EditableLabel_Auto>();
            }
            if (!labelDict.ContainsKey(drawing.GetInstanceID()))
            {
                currentLabel = new EditableLabel_Auto(drawing.SetID);
                labelDict.Add(drawing.GetInstanceID(), currentLabel);
            }
            else
            {
                currentLabel = labelDict[drawing.GetInstanceID()];
            }
            if (!selectorDict.ContainsKey(drawing.GetInstanceID()))
            {
                currentSelector = SpriteSelector.Create_ScaleByWidth();
                selectorDict.Add(drawing.GetInstanceID(), currentSelector);
            }
            else
            {
                currentSelector = selectorDict[drawing.GetInstanceID()];
            }

            if (reference != null && reference.ItemType != drawing.ItemType)
            {
                reference = null;
            }

            GUILayout.BeginVertical(areaOptions);
            drawing.Storage = currentSelector.DrawLayout(drawing.Get <Sprite>() as Sprite, false, areaOptions);
            Rect inputRect = GUILayoutUtility.GetLastRect();

            GUILayout.BeginHorizontal();
            GUILayout.Label("》", GUILayout.Width(10));
            currentLabel.Draw(drawing.ID, true);

            if (reference == null)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("✦", GUILayout.Width(20)))
            {
                PopupWindow.Show(inputRect, new SpriteRefPeeker(reference.Get <Sprite>() as Sprite, reference.containerGroup.database.name, inputRect));
            }
            GUI.enabled = true;
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                drawing.Destroy();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
        }
 public void Awake()
 {
     button     = GetComponent <Button>();
     dispatcher = Service.Get <EventDispatcher>();
     if (SpriteSelector == null)
     {
         SpriteSelector = GetComponent <SpriteSelector>();
     }
 }
Example #5
0
    /// <summary>
    /// Show the selection wizard.
    /// </summary>

    public static void Show(UIAtlas atlas, string selectedSprite, Callback callback)
    {
        SpriteSelector comp = ScriptableWizard.DisplayWizard <SpriteSelector>("Select a Sprite");

        comp.mAtlas    = atlas;
        comp.mSprite   = null;
        comp.mName     = selectedSprite;
        comp.mCallback = callback;
    }
 private void Start()
 {
     Service.Get <EventDispatcher>().AddListener <FindFourEvents.ColorChanged>(onColorChanged);
     spriteSelector = base.transform.parent.parent.Find("Icon").GetComponentInChildren <SpriteSelector>();
     if (spriteSelector == null)
     {
         Log.LogErrorFormatted(this, "Could not find SpriteSelector for button {0}", base.name);
     }
 }
Example #7
0
    /// <summary>
    /// Convenience function that displays a list of sprites and returns the selected value.
    /// </summary>

    static public void DrawAdvancedSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
                                               params GUILayoutOption[] options)
    {
        if (atlas == null)
        {
            return;
        }

        // Give the user a warning if there are no sprites in the atlas
        if (atlas.spriteList.Count == 0)
        {
            EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
            return;
        }

        // Sprite selection drop-down list
        GUILayout.BeginHorizontal();
        {
            if (NGUIEditorTools.DrawPrefixButton("Sprite"))
            {
                NGUISettings.atlas          = atlas;
                NGUISettings.selectedSprite = spriteName;
                SpriteSelector.Show(callback);
            }

            if (editable)
            {
                if (!string.Equals(spriteName, mLastSprite))
                {
                    mLastSprite = spriteName;
                    mEditedName = null;
                }

                string newName = GUILayout.TextField(string.IsNullOrEmpty(mEditedName) ? spriteName : mEditedName);

                if (newName != spriteName)
                {
                    mEditedName = newName;
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
                GUILayout.Space(18f);
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Edit", GUILayout.Width(40f)))
                {
                    NGUISettings.atlas          = atlas;
                    NGUISettings.selectedSprite = spriteName;
                    Select(atlas.gameObject);
                }
            }
        }
        GUILayout.EndHorizontal();
    }
Example #8
0
    public static SpriteSelector Create_Stretch(float maxWidth, float maxHeight)
    {
        SpriteSelector created = new SpriteSelector();

        created.layoutMode = LayoutMode.Stretch;
        created.maxWidth   = maxWidth;
        created.maxHeight  = maxHeight;
        return(created);
    }
Example #9
0
    public static SpriteSelector Create_ScaleByHeight(float maxHeight, float widthRatio = 16, float heightRatio = 9)
    {
        SpriteSelector created = new SpriteSelector();

        created.layoutMode  = LayoutMode.ScaleByHeight;
        created.maxHeight   = maxHeight;
        created.widthRatio  = widthRatio;
        created.heightRatio = heightRatio;
        return(created);
    }
Example #10
0
    public void SetContent()
    {
        SpriteSelector fatherSelector     = sourceFather.GetComponent <SpriteSelector>();
        SpriteSelector motherSelector     = sourceMother.GetComponent <SpriteSelector>();
        SpriteSelector destFatherSelector = destFather.GetComponent <SpriteSelector>();
        SpriteSelector destMotherSelector = destMother.GetComponent <SpriteSelector>();

        SetParentSprites(fatherSelector, destFatherSelector);
        SetParentSprites(motherSelector, destMotherSelector);
    }
    private void DisplayChild(Child child, GameObject childObject)
    {
        SpriteManagement   spriteManagement   = new SpriteManagement();
        GeneCodeManagement geneCodeManagement = new GeneCodeManagement();
        SpriteSelector     childSelector      = childObject.GetComponent <SpriteSelector>();
        bool  isMale = geneCodeManagement.IsMale(child.Gender);
        Chibi chibi  = geneCodeManagement.GetChibiFromChild(child, isMale);

        spriteManagement.SetSpriteFromChibiObject(childSelector, isMale, chibi);
    }
Example #12
0
 private void onUIItemLoaded(string path, GameObject prefab)
 {
     for (int i = 0; i < totalItemsHidden; i++)
     {
         GameObject     gameObject = Object.Instantiate(prefab, ItemsFoundContainer, worldPositionStays: false);
         SpriteSelector component  = gameObject.GetComponent <SpriteSelector>();
         int            index      = (i >= totalItemsFound) ? 1 : 0;
         component.SelectSprite(index);
     }
 }
 public void Awake()
 {
     button        = GetComponent <Button>();
     dispatcher    = Service.Get <EventDispatcher>();
     lastClickTime = -1f;
     curIndex      = 0;
     if (SpriteSelector == null)
     {
         SpriteSelector = GetComponent <SpriteSelector>();
     }
 }
Example #14
0
    /// <summary>
    /// 新增选择精灵 修改:江志祥 2013、04、24
    /// </summary>
    /// <param name="atlas"></param>
    /// <param name="selectedSprite"></param>
    /// <param name="callback"></param>
    public static void Show(UIAtlas atlas, string selectedSprite, SpriteArrayCallback callback, int ArrayID)
    {
        SpriteSelector comp = ScriptableWizard.DisplayWizard <SpriteSelector>("Select a Sprite");

        comp.mAtlas         = atlas;
        comp.mSprite        = null;
        comp.mName          = selectedSprite;
        comp.mCallback      = comp.OnSelectSpriteCallBackFuntion;
        comp.mArrayCallBack = callback;
        comp.SpriteID       = ArrayID;
    }
    // Start is called before the first frame update
    public void Start()
    {
        int boardStyle = new System.Random().Next(Backgrounds.Count);

        this.gameObject.GetComponent <SpriteRenderer>().sprite = Backgrounds[boardStyle];
        Frame = GameObject.Instantiate(Frame, new Vector3(this.transform.position.x, this.transform.position.y, -4), this.transform.rotation);
        Frame.SetSprite(Frames[boardStyle]);
        if (PV.IsMine)
        {
            Manager = FindObjectOfType <GamestateManager>();
        }
    }
Example #16
0
    /// <summary>
    /// Show the selection wizard.
    /// </summary>
    public static void Show(Callback callback)
    {
        if (instance != null)
        {
            instance.Close();
            instance = null;
        }

        SpriteSelector comp = ScriptableWizard.DisplayWizard<SpriteSelector>("Select a Sprite");
        comp.mSprite = null;
        comp.mCallback = callback;
    }
Example #17
0
 private void SetParentSprites(SpriteSelector sourceSelector, SpriteSelector destSelector)
 {
     destSelector.headRenderer.sprite         = sourceSelector.headRenderer.sprite;
     destSelector.faceEyesRenderer.sprite     = sourceSelector.faceEyesRenderer.sprite;
     destSelector.faceEyebrowsRenderer.sprite = sourceSelector.faceEyebrowsRenderer.sprite;
     destSelector.faceEyebrowsRenderer.color  = sourceSelector.faceEyebrowsRenderer.color;
     destSelector.hairMidRenderer.sprite      = sourceSelector.hairMidRenderer.sprite;
     destSelector.hairMidRenderer.color       = sourceSelector.hairMidRenderer.color;
     destSelector.hairBackRenderer.sprite     = sourceSelector.hairBackRenderer.sprite;
     destSelector.hairBackRenderer.color      = sourceSelector.hairBackRenderer.color;
     destSelector.faceRestRenderer.sprite     = sourceSelector.faceRestRenderer.sprite;
 }
        public static bool SetButtonState(DataEntityHandle handle, GameObject buttonGameObject)
        {
            bool           flag  = Service.Get <ZoneTransitionService>().IsInIgloo&& Service.Get <SceneLayoutDataManager>().IsInOwnIgloo();
            ButtonState    index = (flag ? ButtonState.Disabled : ButtonState.Enabled);
            SpriteSelector componentInChildren = buttonGameObject.GetComponentInChildren <SpriteSelector>();

            if (componentInChildren != null)
            {
                componentInChildren.Select((int)index);
            }
            return(flag);
        }
    /// <summary>
    /// Draw a sprite selection field.
    /// </summary>

    static public void SpriteField(string fieldName, UIAtlas atlas, string spriteName,
                                   SpriteSelector.Callback callback, params GUILayoutOption[] options)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label(fieldName, GUILayout.Width(76f));

        if (GUILayout.Button(spriteName, "MiniPullDown", options))
        {
            SpriteSelector.Show(atlas, spriteName, callback);
        }
        GUILayout.EndHorizontal();
    }
    /// <summary>
    /// Show the selection wizard.
    /// </summary>

    static public void Show(SerializedObject ob, SerializedProperty pro, UIAtlas atlas)
    {
        if (ob != null && pro != null && atlas != null)
        {
            SpriteSelector comp = ScriptableWizard.DisplayWizard <SpriteSelector>("Select a Sprite");
            comp.mAtlas    = atlas;
            comp.mSprite   = null;
            comp.mObject   = ob;
            comp.mProperty = pro;
            comp.mName     = pro.hasMultipleDifferentValues ? null : pro.stringValue;
            comp.mCallback = comp.OnSpriteSelection;
        }
    }
Example #21
0
    private bool NeighbourHasWallInDirection(Vector2 neighbourDirection, int directionId)
    {
        RaycastHit2D hit = Physics2D.Raycast(this.gameObject.transform.position, neighbourDirection, 1f, LayerMask.GetMask("Wall"));

        if (hit)
        {
            SpriteSelector selector = hit.collider.gameObject.GetComponent <SpriteSelector>();
            if (selector)
            {
                return(selector.HasWallInDirection(directionId));
            }
        }
        return(false);
    }
Example #22
0
    /// <summary>
    /// Convenience function that displays a list of sprites and returns the selected value.
    /// </summary>

    static public void AdvancedSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, bool editable,
                                           params GUILayoutOption[] options)
    {
        // Give the user a warning if there are no sprites in the atlas
        if (atlas.spriteList.Count == 0)
        {
            EditorGUILayout.HelpBox("No sprites found", MessageType.Warning);
            return;
        }

        // Sprite selection drop-down list
        GUILayout.BeginHorizontal();
        {
            if (GUILayout.Button("Sprite", "DropDownButton", GUILayout.Width(76f)))
            {
                SpriteSelector.Show(atlas, spriteName, callback);
            }

            if (editable)
            {
                string sn = GUILayout.TextField(spriteName);

                if (sn != spriteName)
                {
                    UIAtlas.Sprite sp = atlas.GetSprite(spriteName);

                    if (sp != null)
                    {
                        NGUIEditorTools.RegisterUndo("Edit Sprite Name", atlas);
                        sp.name    = sn;
                        spriteName = sn;
                    }
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(spriteName, "HelpBox", GUILayout.Height(18f));
                GUILayout.Space(18f);
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Edit", GUILayout.Width(40f)))
                {
                    NGUISettings.selectedSprite = spriteName;
                    Select(atlas.gameObject);
                }
            }
        }
        GUILayout.EndHorizontal();
    }
    /// <summary>
    /// Draw a simple sprite selection button.
    /// </summary>

    static public bool SimpleSpriteField(UIAtlas atlas, string spriteName, SpriteSelector.Callback callback, params GUILayoutOption[] options)
    {
        if (atlas.GetSprite(spriteName) == null)
        {
            spriteName = "";
        }

        if (GUILayout.Button(spriteName, "DropDown", options))
        {
            SpriteSelector.Show(atlas, spriteName, callback);
            return(true);
        }
        return(false);
    }
Example #24
0
 void Init()
 {
     if (peeked == null)
     {
         this.height = 48;
     }
     else
     {
         this.height = 160;
     }
     labelStyle          = new GUIStyle(GUI.skin.label);
     labelStyle.wordWrap = true;
     labelStyle.fontSize = 12;
     selector            = SpriteSelector.Create_ScaleByWidth(attached.width);
 }
Example #25
0
 private void getComponents()
 {
     if (image == null)
     {
         image = GetComponent <Image>();
     }
     if (spriteSelector == null)
     {
         spriteSelector = GetComponent <SpriteSelector>();
     }
     if (tintSelector == null)
     {
         tintSelector = GetComponent <TintSelector>();
     }
 }
Example #26
0
    private void SetGeneCode(bool isFather, SpriteSelector selector)
    {
        GeneCodeManagement manageCode = new GeneCodeManagement();
        GameObject         parentGenes;
        List <GenePair>    genePairList = new List <GenePair>();
        GenePair           skinPair     = new GenePair();
        GenePair           eyePair      = new GenePair();
        GenePair           hairPair     = new GenePair();
        GenePair           mouthPair    = new GenePair();
        GenePair           genderPair   = new GenePair();
        ChibiGenes         genes;

        if (isFather)
        {
            parentGenes = fatherGenes;
            genes       = Parents.FATHER_GENES[gameManager.GetFather()];
        }
        else
        {
            parentGenes = motherGenes;
            genes       = Parents.MOTHER_GENES[gameManager.GetMother()];
        }

        // Prepare gene codes
        skinPair = skinPair.SplitGenePair(genes.SkinColor);
        genePairList.Add(skinPair);

        eyePair = eyePair.SplitGenePair(genes.EyesColor);
        genePairList.Add(eyePair);

        hairPair = hairPair.SplitGenePair(genes.HairColor);
        genePairList.Add(hairPair);

        mouthPair = mouthPair.SplitGenePair(genes.Mouth);
        genePairList.Add(mouthPair);

        genderPair = genderPair.SplitGenePair(genes.Gender);
        genePairList.Add(genderPair);

        // Display genes
        for (int i = 0; i < genePairList.Count; i++)
        {
            parentGenes.transform.GetChild(i * 2).transform.GetChild(0).GetComponent <Text>().text     = genePairList[i].gene1;
            parentGenes.transform.GetChild(i * 2 + 1).transform.GetChild(0).GetComponent <Text>().text = genePairList[i].gene2;
        }
    }
Example #27
0
    /// <summary>
    /// Draw a sprite selection field.
    /// </summary>

    static public void SpriteField(string fieldName, string caption, UIAtlas atlas, string spriteName, SpriteSelector.Callback callback)
    {
        GUILayout.BeginHorizontal();
        GUILayout.Label(fieldName, GUILayout.Width(76f));

        if (GUILayout.Button(spriteName, "MiniPullDown", GUILayout.Width(120f)))
        {
            SpriteSelector.Show(atlas, spriteName, callback);
        }

        if (!string.IsNullOrEmpty(caption))
        {
            GUILayout.Space(20f);
            GUILayout.Label(caption);
        }
        GUILayout.EndHorizontal();
    }
Example #28
0
    /// <summary>
    /// Show the sprite selection wizard.
    /// </summary>

    public static void Show(SerializedObject ob, SerializedProperty pro, UIAtlas atlas)
    {
        if (instance != null)
        {
            instance.Close();
            instance = null;
        }

        if (ob != null && pro != null && atlas != null)
        {
            SpriteSelector comp = ScriptableWizard.DisplayWizard <SpriteSelector>("Select a Sprite");
            NGUISettings.atlas          = atlas;
            NGUISettings.selectedSprite = pro.hasMultipleDifferentValues ? null : pro.stringValue;
            comp.mSprite   = null;
            comp.mObject   = ob;
            comp.mProperty = pro;
            comp.mCallback = comp.OnSpriteSelection;
        }
    }
Example #29
0
    /// <summary>
    /// Show the selection wizard.
    /// </summary>

    static public void Show(Callback callback)
    {
        if (instance != null)
        {
            try
            {
                instance.Close();
            }
            catch (System.Exception ex)
            {
                Debug.LogError("What's the f**k!!! ===> " + ex.Message);
            }
            instance = null;
        }

        SpriteSelector comp = ScriptableWizard.DisplayWizard <SpriteSelector>("Select a Sprite");

        comp.mSprite   = null;
        comp.mCallback = callback;
    }
Example #30
0
    //Draw nodes
    void Draw()
    {
        foreach (Node node in nodes)
        {
            //Set Position
            if (node == null)
            {
                continue;
            }
            Vector2 pos = node.posistion;
            pos.x *= spriteSize.x;
            pos.y *= spriteSize.y;

            //Generate sprite
            SpriteSelector spriteSelector = Instantiate(Object as GameObject, pos, Quaternion.identity).GetComponent <SpriteSelector>();
            spriteSelector.id    = node.ID;
            spriteSelector.up    = node.doorTop;
            spriteSelector.down  = node.doorBottom;
            spriteSelector.left  = node.doorLeft;
            spriteSelector.right = node.doorRight;
        }
    }
Example #31
0
	/// <summary>
	/// Show the selection wizard.
	/// </summary>

	static public void Show (Callback callback)
	{
		if (instance != null)
		{
			instance.Close();
			instance = null;
		}

		SpriteSelector comp = ScriptableWizard.DisplayWizard<SpriteSelector>("Select a Sprite");
		comp.mSprite = null;
		comp.mCallback = callback;
	}
Example #32
0
	/// <summary>
	/// Show the sprite selection wizard.
	/// </summary>

	static public void Show (SerializedObject ob, SerializedProperty pro, UIAtlas atlas)
	{
		if (instance != null)
		{
			instance.Close();
			instance = null;
		}

		if (ob != null && pro != null && atlas != null)
		{
			SpriteSelector comp = ScriptableWizard.DisplayWizard<SpriteSelector>("Select a Sprite");
			NGUISettings.atlas = atlas;
			NGUISettings.selectedSprite = pro.hasMultipleDifferentValues ? null : pro.stringValue;
			comp.mSprite = null;
			comp.mObject = ob;
			comp.mProperty = pro;
			comp.mCallback = comp.OnSpriteSelection;
		}
	}
Example #33
0
	void OnDisable () { instance = null; }
Example #34
0
	void OnEnable () { instance = this; }
Example #35
0
	protected string EditSprite(UIAtlas atlas, string label, string sprite, SpriteSelector.Callback callback)
	{
		EditorGUILayout.BeginHorizontal();
		GUILayout.Label(label, GUILayout.Width(76f));

		string buttonLabel = sprite;
		if (string.IsNullOrEmpty(buttonLabel))
			buttonLabel = "...";
		
		if (GUILayout.Button(buttonLabel, itemSpriteOpt))
		{
			NGUISettings.atlas = atlas;
			SpriteSelector.Show(callback);
		}

		GUILayout.Space(12f);
		if (GUILayout.Button("None", itemSpriteDelOpt))
		{
			if (! string.IsNullOrEmpty(sprite))
				RegisterUndo();
			
			sprite = "";
		}
		EditorGUILayout.EndHorizontal();
			
		GUILayout.Space(2f);
	
		return sprite;
	}