Fix material instance parameters order in editor to match from base material
This commit is contained in:
@@ -48,5 +48,11 @@ namespace FlaxEditor.Surface
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[NoSerialize, HideInEditor]
|
[NoSerialize, HideInEditor]
|
||||||
public readonly SurfaceMeta Meta = new SurfaceMeta();
|
public readonly SurfaceMeta Meta = new SurfaceMeta();
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{Type} {Name} = {Value?.ToString() ?? "null"}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace FlaxEditor.Surface
|
|||||||
{
|
{
|
||||||
public GraphParameter Parameter;
|
public GraphParameter Parameter;
|
||||||
public bool IsPublic;
|
public bool IsPublic;
|
||||||
|
public int Index;
|
||||||
public Type Type;
|
public Type Type;
|
||||||
public object Tag;
|
public object Tag;
|
||||||
public Attribute[] Attributes;
|
public Attribute[] Attributes;
|
||||||
@@ -31,15 +32,16 @@ namespace FlaxEditor.Surface
|
|||||||
public HeaderAttribute Header;
|
public HeaderAttribute Header;
|
||||||
public string DisplayName;
|
public string DisplayName;
|
||||||
|
|
||||||
public GraphParameterData(GraphParameter parameter, object tag = null)
|
public GraphParameterData(GraphParameter parameter, int index, object tag = null)
|
||||||
: this(parameter, null, parameter.IsPublic, parameter.Type, SurfaceMeta.GetAttributes(parameter), tag)
|
: this(parameter, index, null, parameter.IsPublic, parameter.Type, SurfaceMeta.GetAttributes(parameter), tag)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public GraphParameterData(GraphParameter parameter, string name, bool isPublic, Type type, Attribute[] attributes, object tag)
|
public GraphParameterData(GraphParameter parameter, int index, string name, bool isPublic, Type type, Attribute[] attributes, object tag)
|
||||||
{
|
{
|
||||||
Parameter = parameter;
|
Parameter = parameter;
|
||||||
IsPublic = isPublic;
|
IsPublic = isPublic;
|
||||||
|
Index = index;
|
||||||
Type = type;
|
Type = type;
|
||||||
Tag = tag;
|
Tag = tag;
|
||||||
Attributes = attributes;
|
Attributes = attributes;
|
||||||
@@ -74,8 +76,14 @@ namespace FlaxEditor.Surface
|
|||||||
if (Editor.Instance.Options.Options.General.ScriptMembersOrder == GeneralOptions.MembersOrder.Alphabetical)
|
if (Editor.Instance.Options.Options.General.ScriptMembersOrder == GeneralOptions.MembersOrder.Alphabetical)
|
||||||
return string.Compare(x.DisplayName, y.DisplayName, StringComparison.InvariantCulture);
|
return string.Compare(x.DisplayName, y.DisplayName, StringComparison.InvariantCulture);
|
||||||
|
|
||||||
// Keep same order
|
// Keep same order (from input indices)
|
||||||
return 0;
|
return x.Index - y.Index;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{Type} {DisplayName}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +214,7 @@ namespace FlaxEditor.Surface
|
|||||||
Profiler.EndEvent();
|
Profiler.EndEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int index = 0;
|
||||||
foreach (var parameter in parameters)
|
foreach (var parameter in parameters)
|
||||||
{
|
{
|
||||||
var parameterId = parameter.ParameterID;
|
var parameterId = parameter.ParameterID;
|
||||||
@@ -229,7 +238,7 @@ namespace FlaxEditor.Surface
|
|||||||
surfaceParameters.Add(surfaceParameter);
|
surfaceParameters.Add(surfaceParameter);
|
||||||
}
|
}
|
||||||
var attributes = surfaceParameter?.Meta.GetAttributes() ?? FlaxEngine.Utils.GetEmptyArray<Attribute>();
|
var attributes = surfaceParameter?.Meta.GetAttributes() ?? FlaxEngine.Utils.GetEmptyArray<Attribute>();
|
||||||
data[i] = new GraphParameterData(null, parameter.Name, parameter.IsPublic, ToType(parameter.ParameterType), attributes, parameter);
|
data[i] = new GraphParameterData(null, index++, parameter.Name, parameter.IsPublic, ToType(parameter.ParameterType), attributes, parameter);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Array.Sort(data, GraphParameterData.Compare);
|
Array.Sort(data, GraphParameterData.Compare);
|
||||||
@@ -243,7 +252,7 @@ namespace FlaxEditor.Surface
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var parameter in parameters)
|
foreach (var parameter in parameters)
|
||||||
{
|
{
|
||||||
data[i] = new GraphParameterData(parameter.EmitterParameter, parameter);
|
data[i] = new GraphParameterData(parameter.EmitterParameter, i, parameter);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Array.Sort(data, GraphParameterData.Compare);
|
Array.Sort(data, GraphParameterData.Compare);
|
||||||
@@ -257,7 +266,7 @@ namespace FlaxEditor.Surface
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (var parameter in parameters)
|
foreach (var parameter in parameters)
|
||||||
{
|
{
|
||||||
data[i] = new GraphParameterData(parameter);
|
data[i] = new GraphParameterData(parameter, i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Array.Sort(data, GraphParameterData.Compare);
|
Array.Sort(data, GraphParameterData.Compare);
|
||||||
|
|||||||
@@ -97,4 +97,13 @@ namespace FlaxEngine
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
partial class MaterialParameter
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{ParameterType} {Name} = {Value?.ToString() ?? "null"}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user