Jump to content

Brush lost materials applied with script after reload


Dreikblack
 Share

Go to solution Solved by Josh,

Recommended Posts

1. Create brush

2. Select face.

3. Apply texture:

local texture = LoadTexture("/Materials/Developer/trigger.dds")
local material = CreateMaterial()
material:SetTexture(texture)
local faces = program.facepanel:GetSelectedFaces() 
			if (#program.facepanel:GetSelectedFaces() > 0) then
				for n = 1, #faces do
					local currentFace = faces[n]
					if currentFace ~= nil then
						currentFace:SetMaterial(material)
						currentFace:GetBrush():Build()
					end  
				end	
				return
			end

4. Select other face and apply other texture:

local texture = LoadTexture("/Materials/Developer/grid01.dds")
local material = CreateMaterial()
material:SetTexture(texture)
local faces = program.facepanel:GetSelectedFaces() 
			if (#program.facepanel:GetSelectedFaces() > 0) then
				for n = 1, #faces do
					local currentFace = faces[n]
					if currentFace ~= nil then
						currentFace:SetMaterial(material)
						currentFace:GetBrush():Build()
					end  
				end	
				return
			end

5. Save map and open again

image.png.bae81a0489cb200e2828fd976ed40c33.pngMaps.zip

Same for prefabs

Also editor starts behave clunky after that - slow with delays and freezes

Link to comment
Share on other sites

  • 2 months later...

Old bug when even without extra textures and faces material is gone returned":

1. Create and select brush

2.

local texture = LoadTexture("/Materials/Developer/trigger.dds")
local material = CreateMaterial()
material:SetTexture(texture)
local selected = program:GetSelection()
    for n = 1, #selected do
        local currentBrush = Brush(selected[n].entity)
        if currentBrush ~= nil then
            currentBrush:SetMaterial(material)
            currentBrush:Build()
        end
    end

3. Save map

4. Change something like brush scale

5. Save and reload map - material is gone

Link to comment
Share on other sites

I think there is a problem here.

  • A benefit of JSON is I can make changes to the scene file format very easily without any effort.
  • A problem of JSON is I can make changes to the scene file format very easily without any effort.

Materials-stored-in-maps, as this is, are something I have not strictly defined because it is something that has never been used. Since the created material has no path associated with it, this is functionality that is completely different from how the editor normally works.

There is some working in the format that indicate this was an idea that did not get used, as many things are. There are many ideas for Ultra I had that I decided were not worth the added complexity, and so they never made it into the final feature set.

Is it possible to apply a material that has a defined path, so that the editor know where to find it?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

5 hours ago, Josh said:

Is it possible to apply a material that has a defined path, so that the editor know where to find it?

Do you mean using usual mats? I have to creating a material in this way via scripts because i'm using quake textures from a pak.

But i just realized that probably i should tried to save such materials as files. If it's possible to use pak textures in mat files it would make things dozen times easier.

I thought mats have textures inside them and only now i tried to open them with Notepaded++ and saw it was a json :o

Link to comment
Share on other sites

  • Solution

If you save the material, then load it again from the path, it will now be a "normal" material with a path, like any other material the editor uses.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...