Color

  • static public void ИзменитьПиксель(int x, int y, Color c)
    {byte size;
    string path;

    string f = "Assets/Resources/"+path+".asset";
    Texture2D img = (Texture2D)AssetDatabase.LoadAssetAtPath(f, typeof(Texture2D));

    Color[] colorArray = img.GetPixels();
    for (byte dx = 0; dx < 4; dx++)
    for (byte dy = 0; dy < 4; dy++)
    colorArray[dx + x + (y + dy) * size] = c;

    AssetDatabase.StartAssetEditing();

    img.SetPixels(colorArray);
    img.Apply();

    AssetDatabase.StopAssetEditing();
    AssetDatabase.SaveAssets();
    AssetDatabase.Refresh();
    }
    [CustomEditor(typeof(Bo52_x.MONO_x))]
    public class gui : Bo52_16102020130441917.MONO_16102020130441917.gui
    {private GameObject go;

    public override void event_MouseMove()
    {RaycastHit HIT;

    Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
    int layerMask = 1 #l##l# 9;

    if (!Physics.Raycast(ray, out HIT, Mathf.Infinity, layerMask))
    return;

    if (HIT.collider == null) return;
    //if (HIT.collider.gameObject.tag == "vertex")
    //Selection.objects = new Object[1] { HIT.collider.gameObject };
    GameObject.Find("Cube").transform.position = HIT.point;
    go=HIT.collider.gameObject;
    //ИзменитьПиксель(x, y, Color c);
    }

    public override void OnSceneGUI()
    {base.OnSceneGUI();
    }
    }

  • [CustomEditor(typeof(START))]
    public class gui : Editor
    {public void OnSceneGUI()
    {if (ОбновлениеРедактора){ОбновлениеРедактора = false;
    Bo52_17102020101208823.MONO_17102020101208823.ВосстановитьПоверхность();
    }
    }

    static Color matColor;
    static public float УменьшитьЯркость(ref Color c){float h = 0;
    float s = 0;
    float v1 = 0;

    Color.RGBToHSV(c, out h, out s, out v1);

    c = Color.HSVToRGB(h, s, v);
    return v;
    }
    static public float УвеличитьЯркость(ref Color c)
    {float h = 0;
    float s = 0;
    float v1 = 0;

    Color.RGBToHSV(c, out h, out s, out v1);

    c = Color.HSVToRGB(h, s, v);
    return v;
    }
    static float v=1.0f;
    public void Цвета(ref Color c){
    matColor = EditorGUILayout.ColorField("New Color", matColor);
    var new_v = Bo52_16102020135416295.STATIC.ползунок(v);
    if (new_v != v){
    if (new_v>v)
    УвеличитьЯркость(ref c);
    else
    УменьшитьЯркость(ref c);
    v = new_v;
    }
    GUILayout.BeginHorizontal();
    GUI.color = Color.black;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.gray;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.green;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.blue;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.cyan;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.yellow;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.magenta;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = Color.red;
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUI.color = new Color(0.85f,0.7f,0.4f);
    if (Bo52_16102020135416295.STATIC.кнопка("", 50))
    c = GUI.color;
    GUILayout.EndHorizontal();
    }

    public override void OnInspectorGUI()
    {((START)target).ИНСПЕКТОР();
    Цвета(ref matColor);
    }
    }

  • Unity => Script (Текстура) - создать текстуру
    static public void ИзменитьТекстуру()
    {Texture2D tex=new Texture2D((int)size, (int)size, TextureFormat.RGBA32, false);
    tex.filterMode = FilterMode.Point;
    tex.wrapMode=TextureWrapMode.Clamp;

    img.SetPixel(x, y, c);
    tex.Apply();

    go.GetComponent#l#MeshRenderer#r#().sharedMaterial.mainTexture = tex;

    Unity => Script (Текстура) - сохранить текстуру
    }