Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     // Need canvas active at the start to update toggles status
     canvas.SetActive(true);
     nameText.text        = AuxiliarFunctions.FirstUpper(Mushroom.Name);
     DescriptionText.text = Mushroom.Description;
     IsEdible.isOn        = Mushroom.IsEdible;
     IsNotEdible.isOn     = Mushroom.IsNotEdible;
     IsRecommended.isOn   = Mushroom.IsRecommended;
     IsPsycotropic.isOn   = Mushroom.IsPsycotropic;
     IsPoisonous.isOn     = Mushroom.IsPoisonous;
     IsDangerous.isOn     = Mushroom.IsDangerous;
     IsDeadly.isOn        = Mushroom.IsDeadly;
     IsUnknown.isOn       = Mushroom.IsUnknown;
     SpeciesText.text     = Mushroom.Species;
     if (Mushroom.Photos.Length != 0)
     {
         for (int i = 0; i < PhotosTexture.Length; i++)
         {
             PhotosTexture[i].texture = Mushroom.Photos[i];
         }
     }
     else
     {
         for (int i = 0; i < PhotosTexture.Length; i++)
         {
             PhotosTexture[i].enabled = false;
         }
     }
     canvas.SetActive(false);
 }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            MushroomScriptableObject mushScrObj = (MushroomScriptableObject)target;

            if (GUILayout.Button("Random pick photos"))
            {
                string sDataPath           = Application.dataPath;
                string capitalizedMushName = AuxiliarFunctions.FirstUpper(mushScrObj.Name);
                string sFolderPath         = sDataPath.Substring(0, sDataPath.Length - 6) + "Assets/Art/2D/Mushrooms/" + capitalizedMushName;
                Debug.Log("A: " + sFolderPath);
                string[]       aFilePaths = Directory.GetFiles(sFolderPath, "*.jpg");
                List <Texture> textures;
                textures = new List <Texture>();
                foreach (string sFilePath in aFilePaths)
                {
                    string sAssetPath = sFilePath.Substring(sDataPath.Length - 6);
                    Object objAsset   = AssetDatabase.LoadAssetAtPath(sAssetPath, typeof(Object));
                    textures.Add((Texture2D)objAsset);
                }
                RandomPickPhotos(mushScrObj, textures);
            }
        }