This repository was archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathCustomModuleEditor.cs
More file actions
50 lines (48 loc) · 1.42 KB
/
Copy pathCustomModuleEditor.cs
File metadata and controls
50 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
namespace Wanderer.GameFramework
{
[AttributeUsage(AttributeTargets.Class)]
public class CustomModuleEditor : Attribute
{
/// <summary>
/// 模块名称
/// </summary>
/// <value></value>
public string Name { get; private set; }
/// <summary>
/// 模块颜色
/// </summary>
/// <value></value>
public Color Color { get; private set; }
public CustomModuleEditor(string name)
{
Name = name;
Color = RandomColor();
}
public CustomModuleEditor(string name, float x, float y, float z)
{
Name = name;
Color = new Color(x, y, z);
}
private Color RandomColor()
{
float x = UnityEngine.Random.Range(0, 1.0f);
float y = 1 - x;
float z = UnityEngine.Random.Range(0, 1.0f);
List<float> values = new List<float>();
values.Add(x);
values.Add(y);
values.Add(z);
while (values.Count > 0)
{
int index = UnityEngine.Random.Range(0, values.Count);
x = values[index];
values.RemoveAt(index);
}
return new Color(x, y, z);
}
}
}