Ejemplo n.º 1
0
        public static string GetFragmentShaderFromClassType(Type type)
        {
            GrassMaterialAttribute attr = GetAttributeFromClassType(type);

            if (attr == null || string.IsNullOrEmpty(attr.fragmentShader))
            {
                return("GrassSurfaces/GrassLambertianSurface.cginc");
            }
            return(attr.fragmentShader);
        }
Ejemplo n.º 2
0
        public static string GetSurfFromClassType(Type type)
        {
            GrassMaterialAttribute attr = GetAttributeFromClassType(type);

            if (attr == null || string.IsNullOrEmpty(attr.surf))
            {
                return("Lambert");
            }
            return(attr.surf);
        }
Ejemplo n.º 3
0
        public static string GetFileNameFromClassType(Type type)
        {
            GrassMaterialAttribute attr = GetAttributeFromClassType(type);

            if (attr == null || string.IsNullOrEmpty(attr.fileName))
            {
                return(type.Name);
            }
            return(attr.fileName);
        }
Ejemplo n.º 4
0
        private void CreateNewMaterialProfileMenu(SerializedProperty property)
        {
            List <Type> types = AssetsManager.GetListOfType(typeof(GrassMaterialProfile));
            GenericMenu menu  = new GenericMenu();

            foreach (Type type in types)
            {
                menu.AddItem(new GUIContent(GrassMaterialAttribute.GetNameFromClassType(type)), false, () => { CreateNewProfile(type, property); });
            }
            menu.ShowAsContext();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets (global) <see cref="GrassMaterialProfile"/> settings if current <see cref="GrassManager"/> is not a prefab
        /// </summary>
        public void CorrectGrassMaterialSettings()
        {
            if (IsPrefabOrMultipleManagers())
            {
                return;
            }

            string shaderPath = AssetsManager.GetGrassAssetPath() + "/Shaders/WavingGrassPhysics.shader";

            System.Type materialType = null;
            if (grassMaterial != null)
            {
                materialType = grassMaterial.GetType();
            }
            AssetsManager.SetGrassFragmentInclude(GrassMaterialAttribute.GetFragmentShaderFromClassType(materialType));
            AssetsManager.SetSurfInShaderFile(shaderPath, GrassMaterialAttribute.GetSurfFromClassType(materialType));
        }
Ejemplo n.º 6
0
        private void CreateNewProfile(Type type, SerializedProperty property)
        {
            GrassMaterialProfile profile = AssetsManager.CreateNewScriptableObjectOfType(type,
                                                                                         "Grass Material location",
                                                                                         AssetsManager.GetScenePath(property),
                                                                                         GrassMaterialAttribute.GetFileNameFromClassType(type),
                                                                                         "asset") as GrassMaterialProfile;

            if (null != profile)
            {
                property.objectReferenceValue = profile;
                property.serializedObject.ApplyModifiedProperties();
            }
        }