Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I saw this question, but this solution did not help me.
In custom editor window I set Standart shader to some materials. Materials were loaded from folders in project:
List<Material> materials = new List<Material>();
string[] _matPaths = FindAssetPathsWithExtension(".mat", folderWithMaterials);
foreach (string materialPath in _matPaths)
{
Material mat = AssetDatabase.LoadAssetAtPath(materialPath, typeof(Material)) as Material;
if (mat != null) { materials.Add(mat); }
}
string filePath = "";
for (int i = 0; i < materials.Count; i++)
{
materials[i].shader = Shader.Find("Standart");
Debug.Log(materials[i].shader);
}
Graphics settings screenshot:
Debug log:
Hidden/InternalErrorShader (UnityEngine.Shader)
I'm 120% sure it's not called standarT (standard maybe?). If you wanna know what a shader's name is, you'll have to look at the source. You can grab the source for Unity's built-in shaders from the downloads section of their website.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
this for loop inside arrays is working like while and printing only the second index.
what should i do to make it print only even indexes?
You have inverted the += operator in your for loop. You're saying i = +2 which is the same as i = 2
The correct code would be:
for (int i = 0; i < cars.Length; i += 2)
{
Console.WriteLine(cars[i]);
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm trying to check specific folder exists. For example, checking folder named "Downloads" exists. I'm writing using C# Windows Forms app and this is code:
//key = Folder Name
{
var pathtu = Convert.ToBoolean(Directory.EnumerateDirectories(main,key,SearchOption.AllDirectories));
if (pathtu == true)
{
path[0] = #"c:\Users\"+key;
File.Move(file.SelectedPath, path[0]);
label2.Visible = true;
}
When I run this code I get the following error:
System.InvalidCastException: 'Unable to cast object of type 'System.IO.FileSystemEnumerableIterator`1[System.String]' to type 'System.IConvertible'.'
What am I doing incorrectly?
Use
Directory.Exists(pathtodir)
It returns a bool.
See https://learn.microsoft.com/en-us/dotnet/api/system.io.directory.exists
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
My question is part of this problem:
I recieve a collection of id's from a form. I need to get the keys, convert them to string and pass it to the db.
using (var db = new DbAmsecEntities())
{
cashsafelist = (from safe in db.Cashsafes
where safe.StoreId == (decimal)Convert.ToInt64(ddlLocationLists.SelectedValue)
select safe.CashsafeId).ToList();
cashsafevalues = cashsafelist.Select(x => x.ToString).ToList();//getting error here
}
You need to use () in ToString
cashsafevalues = cashsafelist.Select(x => x.ToString()).ToList();
You can also use List.ConvertAll which was available since 2.0.
cashsafevalues = cashsafelist.ConvertAll<string>(d => d.ToString());
It can be more efficient than ToList because the list will be initialized with the correct size.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have this code
Button[] ButtonArray = { btn1, btn2, btn3 };
for (int i = 0; i >= 3; i++)
{
ButtonArray[i].Text = loadData[i];
}
What I try to do is that in the buttons btn1, btn2 and btn3 loads the data from loadData array in its text property
When running the program it doesn't load anything.
You put i >= 3 instead of i <= 3. Flip it and you should be good.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
How could I write a while loop that said the following (pseudo code):
While the index of "blahblah" in string 1 exists
do this
while(string1.Contains("blahblah")) {
// do this
}
Pseudocode compiled to C# successfully. 0 errors, 0 warnings. Time taken: 0:00:01.860.
var string1 = "blahblah blahblah blahblah blahblah ";
int pos = -1;
while (0 >= (pos = string1.IndexOf("blahblah", pos + 1)))
{
// do this.
}