Exemple #1
0
 public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
 {
     if (crosshair.sprite != null)
     {
         return(PreviewUtil.RenderStaticPreview(crosshair.sprite, width, height));
     }
     return(Base64ToTexture(icon));
 }
        public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
        {
            if (tile.m_DefaultSprite != null)
            {
                return(PreviewUtil.RenderStaticPreview(tile.m_DefaultSprite, width, height));
            }

            return(base.RenderStaticPreview(assetPath, subAssets, width, height));
        }
Exemple #3
0
    private void DrawSettings()
    {
        inventory.max = EditorGUILayout.Slider("Storage Space", inventory.max, 1, 1000);
        EditorGUILayout.Space();
        GUILayout.Label("Content Filter:", EditorStyles.largeLabel);
        GUILayout.Label("Tags:");

        // show tags
        GUILayout.BeginHorizontal();
        for (int t = 0; t < inventory.canHoldTags.Count; t++)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.ExpandWidth(false));
            if (inventory.canHoldTags[t].sprite != null)
            {
                GUILayout.Label(PreviewUtil.RenderStaticPreview(inventory.canHoldTags[t].sprite, 20, 20));
            }
            GUILayout.Label(inventory.canHoldTags[t].name);
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                inventory.canHoldTags.RemoveAt(t);
                EditorUtility.SetDirty(target);
            }
            GUILayout.EndHorizontal();
        }
        ItemTag tt = (ItemTag)EditorGUILayout.ObjectField(null, typeof(ItemTag), false);

        if (tt != null)
        {
            if (!inventory.canHoldTags.Contains(tt))
            {
                inventory.canHoldTags.Add(tt);
                EditorUtility.SetDirty(target);
            }
        }
        GUILayout.EndHorizontal();


        EditorGUILayout.Space();
        GUILayout.Label("Item Types:");
        // show types
        foreach (ItemType itm in inventory.CanHoldItems)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            if (itm.sprite != null)
            {
                GUILayout.Label(PreviewUtil.RenderStaticPreview(itm.sprite, 20, 20));
            }
            GUILayout.Label(itm.display_name);
            GUILayout.EndHorizontal();
        }
        if (GUILayout.Button("Search for Items with Tags"))
        {
            FindItemTypes();
        }
    }
 public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
 {
     if (itemType.sprite != null)
     {
         return(PreviewUtil.RenderStaticPreview(itemType.sprite, width, height));
     }
     foreach (ItemTag t in itemType.tags)
     {
         if (t.sprite != null)
         {
             return(PreviewUtil.RenderStaticPreview(t.sprite, width, height));
         }
     }
     return(Base64ToTexture(icon));
 }
Exemple #5
0
    private void DrawDefaultContents()
    {
        GUILayout.Label("Space: " + (inventory.FillPercentDefaults() * inventory.max).ToString() + " / " + inventory.max.ToString());
        for (int i = 0; i < inventory.default_items.Count; i++)
        {
            if (inventory.default_items[i].itemType == null)
            {
                inventory.default_items.RemoveAt(i);
                if (i >= inventory.default_items.Count)
                {
                    break;
                }
            }
            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            if (inventory.default_items[i].itemType.sprite == null)
            {
                GUILayout.Label(new GUIContent(inventory.default_items[i].itemType.display_name, Base64ToTexture(item_icon)), GUILayout.Height(20), GUILayout.Width(150));
            }
            else
            {
                GUILayout.Label(new GUIContent(inventory.default_items[i].itemType.display_name, PreviewUtil.RenderStaticPreview(inventory.default_items[i].itemType.sprite, 20, 20)), GUILayout.Width(150));
            }
            GUILayout.Box(inventory.default_items[i].itemType.size.ToString());
            inventory.default_items[i].itemType = (ItemType)EditorGUILayout.ObjectField(inventory.default_items[i].itemType, typeof(ItemType), false, GUILayout.Width(50));
            inventory.default_items[i].count    = EditorGUILayout.Slider(inventory.default_items[i].count, 1, inventory.MaxItemCountDefaults(inventory.default_items[i].itemType));
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                inventory.default_items.RemoveAt(i);
            }
            GUILayout.EndHorizontal();
        }
        ItemType item = (ItemType)EditorGUILayout.ObjectField("Add New Item: ", null, typeof(ItemType), false);

        if (item != null)
        {
            bool isNew = true;
            foreach (Inventory.ItemSlot slot in inventory.default_items)
            {
                if (slot.itemType == item && slot.count + 1 < slot.itemType.max_stack && isNew)
                {
                    isNew = false;
                    slot.count++;
                    break;
                }
            }

            if (isNew)
            {
                inventory.default_items.Add(new Inventory.ItemSlot(item));
                EditorUtility.SetDirty(inventory);
            }
        }
    }
 public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height)
 {
     return(PreviewUtil.RenderStaticPreview(tile.defaultSprite, width, height));
 }
Exemple #7
0
    public override void OnInspectorGUI()
    {
        GUIStyle style = new GUIStyle();

        style.normal.background = null;
        style.hover.background  = null;
        style.active.background = null;

        //base.OnInspectorGUI();
        manager.defaultZone  = (Zone)EditorGUILayout.ObjectField("Default Zone", manager.defaultZone, typeof(Zone), false);
        manager.currentZone  = (StringVariable)EditorGUILayout.ObjectField("Current Zone", manager.currentZone, typeof(StringVariable), false);
        manager.loadDistance = EditorGUILayout.IntSlider("Load Distance", manager.loadDistance, 1, 10);
        EditorGUILayout.Space();
        if (GUILayout.Button("Find Zones"))
        {
            manager.zones.Clear();
            string[] scenes = AssetDatabase.FindAssets("t:Scene");
            string[] zones  = AssetDatabase.FindAssets("t:Zone");
            foreach (string z in zones)
            {
                Zone zz = (Zone)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(z), typeof(Zone));
                if (!manager.zones.Contains(zz))
                {
                    manager.zones.Add(zz);
                }
            }
            foreach (string scene in scenes)
            {
                if (AssetDatabase.GUIDToAssetPath(scene).Contains("/Zones/"))
                {
                    string[] path      = AssetDatabase.GUIDToAssetPath(scene).Split('/');
                    string   zone_path = "";
                    for (int i = 0; i < path.Length - 1; i++)
                    {
                        zone_path += path[i] + "/";
                    }
                    string zone = path[path.Length - 1].Replace(".unity", "");
                    // now see if we can find the zones
                    bool exists = false;
                    foreach (Zone z in manager.zones)
                    {
                        if (z.name == zone)
                        {
                            exists = true;
                        }
                    }
                    if (!exists)
                    {
                        Zone nZone = ScriptableObject.CreateInstance <Zone>();
                        nZone.zone         = zone;
                        nZone.name         = zone;
                        nZone.display_name = zone;
                        AssetDatabase.CreateAsset(nZone, zone_path + zone + ".asset");
                        if (!manager.zones.Contains(nZone))
                        {
                            manager.zones.Add(nZone);
                        }
                    }
                }
            }
        }
        EditorGUILayout.Space();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Icon", GUILayout.Width(65));
        //GUILayout.Space(65);
        GUILayout.Space(20);
        GUILayout.Label("Zone", GUILayout.Width(128), GUILayout.Height(20));
        GUILayout.Label("Description", GUILayout.ExpandWidth(true));
        GUILayout.Label("Neighbors", GUILayout.Width(65));
        GUILayout.EndHorizontal();
        foreach (Zone zone in manager.zones)
        {
            GUILayout.BeginHorizontal();
            zone.sprite = (Sprite)EditorGUILayout.ObjectField(zone.sprite, typeof(Sprite), false, GUILayout.Width(65));
            if (zone.sprite != null)
            {
                GUILayout.Label(PreviewUtil.RenderStaticPreview(zone.sprite, 20, 20), GUILayout.Width(20));
            }
            else
            {
                GUILayout.Label(Base64ToTexture(zone_icon), GUILayout.Width(20));
            }
            //GUILayout.Label(zone.zone,GUILayout.Height(20),GUILayout.ExpandWidth(true));
            if (zone.display_name == "")
            {
                zone.display_name = zone.name;
            }
            zone.display_name = EditorGUILayout.TextField(zone.display_name, GUILayout.Width(128));
            zone.description  = EditorGUILayout.TextField(zone.description);

            if (editing.ContainsKey(zone))
            {
                if (GUILayout.Button("^", GUILayout.Width(40)))
                {
                    editing.Remove(zone);
                }
            }
            else
            {
                if (zone.neighbor.Count == 0)
                {
                    if (GUILayout.Button("Add", GUILayout.Width(40)))
                    {
                        editing.Add(zone, true);
                    }
                }
                else
                {
                    if (GUILayout.Button(zone.neighbor.Count.ToString(), GUILayout.Width(40)))
                    {
                        editing.Add(zone, true);
                    }
                }
            }
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
            }
            GUILayout.EndHorizontal();
            if (editing.ContainsKey(zone))
            {
                GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical();

                GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                GUILayout.Label("Neighbors:", GUILayout.Width(128));
                GUILayout.Label("Distance:");
                GUILayout.EndHorizontal();

                foreach (Zone zz in manager.zones)
                {
                    if (zz != zone)
                    {
                        GUILayout.BeginHorizontal();
                        if (zone.neighbor.Contains(zz))
                        {
                            if (GUILayout.Button(Base64ToTexture(linked), style, GUILayout.Width(20)))
                            {
                                zone.neighbor.Remove(zz);
                                if (zz.neighbor.Contains(zone))
                                {
                                    zz.neighbor.Remove(zone);
                                }
                            }
                        }
                        else
                        {
                            if (GUILayout.Button(Base64ToTexture(unlinked), style, GUILayout.Width(20)))
                            {
                                zone.neighbor.Add(zz);
                                if (!zz.neighbor.Contains(zone))
                                {
                                    zz.neighbor.Add(zone);
                                }
                            }
                        }
                        GUILayout.Label(zz.name, GUILayout.Width(128));
                        if (zone.neighbor.Count > 0)
                        {
                            int d = zz.Distance(zone.zone);
                            if (d != 10)
                            {
                                GUILayout.Label(d.ToString());
                            }
                        }

                        GUILayout.EndHorizontal();
                    }
                }



                GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndHorizontal();
            }
        }
    }
Exemple #8
0
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Name", GUILayout.Width(label_width));
        playerItem.display_name = EditorGUILayout.TextField(playerItem.display_name);
        GUILayout.EndHorizontal();


        GUILayout.BeginHorizontal();
        GUILayout.Label("Sprite", GUILayout.Width(label_width));
        playerItem.sprite = (Sprite)EditorGUILayout.ObjectField(playerItem.sprite, typeof(Sprite), false);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Prefab", GUILayout.Width(label_width));
        playerItem.prefab = (GameObject)EditorGUILayout.ObjectField(playerItem.prefab, typeof(GameObject), false);
        GUILayout.EndHorizontal();


        GUILayout.BeginHorizontal();
        GUILayout.Label("Size", GUILayout.Width(label_width));
        playerItem.width = EditorGUILayout.IntField(playerItem.width);
        GUILayout.Label("x");
        playerItem.height = EditorGUILayout.IntField(playerItem.height);
        GUILayout.Label("Max Stacks", GUILayout.Width(80));
        playerItem.max_stack = EditorGUILayout.FloatField(playerItem.max_stack);
        GUILayout.EndHorizontal();

        playerItem.size = playerItem.width * playerItem.height;

        GUILayout.Label("Description:");
        playerItem.description = EditorGUILayout.TextArea(playerItem.description);

        // show tags
        GUILayout.BeginHorizontal();
        for (int t = 0; t < playerItem.tags.Count; t++)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.ExpandWidth(false));
            if (playerItem.tags[t].sprite != null)
            {
                GUILayout.Label(PreviewUtil.RenderStaticPreview(playerItem.tags[t].sprite, 20, 20));
            }
            GUILayout.Label(playerItem.tags[t].name);
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                playerItem.tags.RemoveAt(t);
            }
            GUILayout.EndHorizontal();
        }
        ItemTag tt = (ItemTag)EditorGUILayout.ObjectField(null, typeof(ItemTag), false);

        if (tt != null)
        {
            if (!playerItem.tags.Contains(tt))
            {
                EditorUtility.SetDirty(target);
                playerItem.tags.Add(tt);
            }
        }
        GUILayout.EndHorizontal();


        GUILayout.EndVertical();
        if (playerItem.width > 3)
        {
            playerItem.width = 3;
        }
        if (playerItem.width < 1)
        {
            playerItem.width = 1;
        }

        if (playerItem.height > 3)
        {
            playerItem.height = 3;
        }
        if (playerItem.height < 1)
        {
            playerItem.height = 1;
        }
        playerItem.sprite = (Sprite)EditorGUILayout.ObjectField("", playerItem.sprite, typeof(Sprite), false, GUILayout.Width(128), GUILayout.Height(128));

        GUILayout.EndHorizontal();
        EditorGUILayout.Space();

        GUILayout.Label("Nouns and Verbs:");
        GUILayout.BeginVertical(EditorStyles.helpBox);
        GUILayout.BeginHorizontal();
        GUILayout.Label("You");
        playerItem.verb_past          = EditorGUILayout.TextField(playerItem.verb_past);
        playerItem.indefinite_article = (ItemType.indefiniateArticle)EditorGUILayout.EnumPopup(playerItem.indefinite_article, GUILayout.Width(50));
        playerItem.display_name       = EditorGUILayout.TextField(playerItem.display_name);
        GUILayout.Label("today.");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        //GUILayout.Label("You");
        playerItem.verb_present = EditorGUILayout.TextField(playerItem.verb_present);
        GUILayout.Label("some");
        playerItem.plural_name = EditorGUILayout.TextField(playerItem.plural_name);
        //GUILayout.Label("now.");
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("You will");
        playerItem.verb_future = EditorGUILayout.TextField(playerItem.verb_future);
        GUILayout.Label("more");
        playerItem.plural_name = EditorGUILayout.TextField(playerItem.plural_name);
        GUILayout.Label("tomorrow.");
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        EditorGUILayout.Space();

        GUILayout.Label("Use Affects:");
        for (int i = 0; i < playerItem.affect.Count; i++)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox);
            GUILayout.Label(playerItem.affect[i].display_name);
            GUILayout.Label(playerItem.affect[i].discription);
            playerItem.affect[i] = (ItemAffect)EditorGUILayout.ObjectField(playerItem.affect[i], typeof(ItemAffect), false, GUILayout.Width(80));
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                playerItem.affect.Remove(playerItem.affect[i]);
                i--;
            }
            GUILayout.EndHorizontal();
        }
        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();
        EditorGUILayout.Space();
        GUILayout.Label("Add Use Affect: ");
        ItemAffect itemAffect = (ItemAffect)EditorGUILayout.ObjectField(null, typeof(ItemAffect), false);

        GUILayout.EndHorizontal();
        if (itemAffect != null)
        {
            playerItem.affect.Add(itemAffect);
        }

        playerItem.name = playerItem.display_name;
    }
    public override void OnInspectorGUI()
    {
        //base.OnInspectorGUI();
        GUILayout.BeginHorizontal();
        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Name", GUILayout.Width(label_width));
        itemType.display_name = EditorGUILayout.TextField(itemType.display_name);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Sprite", GUILayout.Width(label_width));
        itemType.sprite = (Sprite)EditorGUILayout.ObjectField(itemType.sprite, typeof(Sprite), false);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Size", GUILayout.Width(label_width));
        itemType.size = EditorGUILayout.FloatField(itemType.size);
        GUILayout.Label("Max Stacks", GUILayout.Width(80));
        itemType.max_stack = EditorGUILayout.FloatField(itemType.max_stack);
        GUILayout.EndHorizontal();


        GUILayout.Label("Description:");
        itemType.description = GUILayout.TextArea(itemType.description);

        if (itemType.tags == null)
        {
            itemType.tags = new List <ItemTag>();
        }
        // show tags
        GUILayout.BeginHorizontal();
        for (int t = 0; t < itemType.tags.Count; t++)
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.ExpandWidth(false));
            if (itemType.tags[t].sprite != null)
            {
                GUILayout.Label(PreviewUtil.RenderStaticPreview(itemType.tags[t].sprite, 20, 20));
            }
            GUILayout.Label(itemType.tags[t].name);
            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                itemType.tags.RemoveAt(t);
                EditorUtility.SetDirty(target);
            }
            GUILayout.EndHorizontal();
        }
        ItemTag tt = (ItemTag)EditorGUILayout.ObjectField(null, typeof(ItemTag), false);

        if (tt != null)
        {
            if (!itemType.tags.Contains(tt))
            {
                itemType.tags.Add(tt);
                EditorUtility.SetDirty(target);
            }
        }
        GUILayout.EndHorizontal();


        GUILayout.EndVertical();

        itemType.sprite = (Sprite)EditorGUILayout.ObjectField("", itemType.sprite, typeof(Sprite), false, GUILayout.Width(100), GUILayout.Height(100));
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();

        GUILayout.Label("Sentences:");
        GUILayout.BeginHorizontal();
        GUILayout.Label("There is");
        itemType.indefinite_article = (ItemType.indefiniateArticle)EditorGUILayout.EnumPopup(itemType.indefinite_article, GUILayout.Width(50));
        itemType.display_name       = EditorGUILayout.TextField(itemType.display_name);
        GUILayout.Label("on the table.");
        GUILayout.EndHorizontal();

        if (itemType.indefinite_article != ItemType.indefiniateArticle.None)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("There are two");
            itemType.plural_name = EditorGUILayout.TextField(itemType.plural_name);
            GUILayout.Label("on the table.");
            GUILayout.EndHorizontal();
        }
        else
        {
            GUILayout.BeginHorizontal();
            GUILayout.Label("There are two units of");
            itemType.plural_name = EditorGUILayout.TextField(itemType.plural_name);
            GUILayout.Label("on the table.");
            GUILayout.EndHorizontal();
        }
    }