Ejemplo n.º 1
0
        // TODO: Use a parent class, this looks ridiculous
        // TODO: Use a parent class, this looks ridiculous
        // TODO: Use a parent class, this looks ridiculous
        public void RefreshNoTexValueAndNormalUnpack()
        {
            bool newAssetIsNormalMap = false;

            string path = AssetDatabase.GetAssetPath(textureAsset);

            if (string.IsNullOrEmpty(path))
            {
                newAssetIsNormalMap = false;
            }
            else
            {
                AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(path);
                if (importer is TextureImporter)
                {
                    newAssetIsNormalMap = ((TextureImporter)importer).textureType == TextureImporterType.NormalMap;
                }
                else
                {
                    newAssetIsNormalMap = false;                     // When it's a RenderTexture
                }
            }

            if (newAssetIsNormalMap)
            {
                noTexValue        = NoTexValue.Bump;
                markedAsNormalMap = true;
            }
            else if (noTexValue == NoTexValue.Bump)
            {
                noTexValue        = NoTexValue.Black;
                markedAsNormalMap = false;
            }
        }
Ejemplo n.º 2
0
        public override void DrawLowerPropertyBox()
        {
            GUI.color = Color.white;
            EditorGUI.BeginChangeCheck();
            Rect tmp = lowerRect;

            tmp.height = 16f;
            if (!IsGlobalProperty())
            {
                noTexValue = (NoTexValue)UndoableLabeledEnumPopup(tmp, "Default", noTexValue, "swith default color of " + property.nameDisplay);
                //noTexValue = (NoTexValue)SF_GUI.LabeledEnumField( tmp, "Default", noTexValue, EditorStyles.miniLabel );
                tmp.y += tmp.height;
            }
            bool preMarked = markedAsNormalMap;

            UndoableToggle(tmp, ref markedAsNormalMap, "Normal map", "normal map decode of " + property.nameDisplay, null);
            //markedAsNormalMap = GUI.Toggle(tmp, markedAsNormalMap, "Normal map" );
            if (EditorGUI.EndChangeCheck())
            {
                if (markedAsNormalMap && !preMarked)
                {
                    noTexValue = NoTexValue.Bump;
                }
                OnUpdateNode();
            }
        }
Ejemplo n.º 3
0
        // TODO: Use a parent class, this looks ridiculous
        // TODO: Use a parent class, this looks ridiculous
        // TODO: Use a parent class, this looks ridiculous
        public void RefreshNoTexValueAndNormalUnpack()
        {
            bool newAssetIsNormalMap = false;

            string path = AssetDatabase.GetAssetPath(textureAsset);

            if (string.IsNullOrEmpty(path))
            {
                newAssetIsNormalMap = false;
            }
            else
            {
                AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(path);
                if (importer is TextureImporter)
                {
                    newAssetIsNormalMap = ((TextureImporter)importer).textureType == TextureImporterType.NormalMap;
                }
                //else if(textureAsset is ProceduralTexture && textureAsset.name.EndsWith("_Normal"))
                //	newAssetIsNormalMap = true; // When it's a ProceduralTexture having _Normal as a suffix
                //else
                newAssetIsNormalMap = false;                         // When it's a RenderTexture or ProceduralTexture
            }

            if (newAssetIsNormalMap)
            {
                noTexValue        = NoTexValue.Bump;
                markedAsNormalMap = true;
            }
            else if (noTexValue == NoTexValue.Bump)
            {
                noTexValue        = NoTexValue.Black;
                markedAsNormalMap = false;
            }
        }
Ejemplo n.º 4
0
		public override void DeserializeSpecialData( string key, string value ) {
			property.Deserialize( key, value );
			switch( key ) {
				case "tex":
					textureAsset = (Texture)SF_Tools.GUIDToAsset( value, typeof( Texture ) );
					OnAssignedTexture();
					break;
				case "ntxv":
					noTexValue = (NoTexValue)int.Parse( value );
					break;
				case "isnm":
					markedAsNormalMap = bool.Parse( value );
					break;
			}
		}
Ejemplo n.º 5
0
        public override string GetInitializationLine()
        {
            //string defaultValue = isBumpmap ? "\"bump\"" : "\"white\"";

            NoTexValue noTexValue = NoTexValue.Black;

            if (base.node is SFN_Tex2d)
            {
                noTexValue = (base.node as SFN_Tex2d).noTexValue;
            }
            else if (base.node is SFN_Tex2dAsset)
            {
                noTexValue = (base.node as SFN_Tex2dAsset).noTexValue;
            }

            return(GetTagString() + GetVariable() + " (\"" + nameDisplay + "\", 2D) = \"" + noTexValue.ToString().ToLower() + "\" {}");
        }
Ejemplo n.º 6
0
        public void RefreshNoTexValueAndNormalUnpack()
        {
            bool newAssetIsNormalMap = false;

            string path = AssetDatabase.GetAssetPath(TextureAsset);

            if (string.IsNullOrEmpty(path))
            {
                newAssetIsNormalMap = false;
            }
            else
            {
                AssetImporter importer = UnityEditor.AssetImporter.GetAtPath(path);
                if (importer is TextureImporter)
                {
                    newAssetIsNormalMap = ((TextureImporter)importer).textureType == TextureImporterType.NormalMap;
                }
#if UNITY_2018
#else
                else if (TextureAsset is ProceduralTexture && TextureAsset.name.EndsWith("_Normal"))
                {
                    newAssetIsNormalMap = true;                     // When it's a ProceduralTexture having _Normal as a suffix
                }
#endif

                else
                {
                    newAssetIsNormalMap = false; // When it's a RenderTexture or ProceduralTexture
                }
            }

            if (newAssetIsNormalMap)
            {
                noTexValue        = NoTexValue.Bump;
                markedAsNormalMap = true;
                UpdateNormalMapAlphaState();
            }
            else if (noTexValue == NoTexValue.Bump)
            {
                noTexValue        = NoTexValue.Black;
                markedAsNormalMap = false;
                UpdateNormalMapAlphaState();
            }

            UpdateCompCount();
        }
Ejemplo n.º 7
0
        public override void DrawLowerPropertyBox()
        {
            GUI.color = Color.white;
            EditorGUI.BeginChangeCheck();
            Rect tmp = lowerRect;

            tmp.height = 16f;
            noTexValue = (NoTexValue)UndoableLabeledEnumPopup(tmp, "Default", noTexValue, "swith default color of " + property.nameDisplay);
            tmp.y     += tmp.height;
            bool preMarked = markedAsNormalMap;


            UndoableToggle(tmp, ref markedAsNormalMap, "Normal map", "normal map decode of " + property.nameDisplay, null);
            //markedAsNormalMap = GUI.Toggle(tmp, markedAsNormalMap, "Normal map" );

            if (EditorGUI.EndChangeCheck())
            {
                if (markedAsNormalMap && !preMarked)
                {
                    noTexValue = NoTexValue.Bump;
                }
                UpdateCompCount();
                UpdateNormalMapAlphaState();
                OnUpdateNode();
            }
            Vector2 tl   = tmp.TopLeft();
            Rect    tmp2 = new Rect(tl.x, tl.y + 16f, tmp.width - 32f, 32f);
            //tmp2.height = 32f;
            float oldIdx = Index;

            Index = UndoableFloatField(tmp2, Index, "idx", SF_Styles.LargeTextField);
            if (oldIdx != Index)
            {
                OnAssignedTexture();
            }
        }