示例#1
0
    //------------------------------------

    void Awake()
    {
        if (!instance)
        {
            instance = this;
        }
    }
示例#2
0
        internal void SetBoardState(GameCell[] Field)
        {
            if (!_inited)
            {
                Debug.LogError($"View has not been inited!");
                return;
            }

            if (Field.Length != _changeableObjects.Count)
            {
                Debug.LogError($"Different dimensions!");
                return;
            }

            var cells   = new NativeArray <GameCell>(_changeableObjects.Count, Allocator.TempJob);
            var indexes = new NativeArray <int>(_changeableObjects.Count, Allocator.TempJob);
            var colors  = new NativeArray <Color>(_changeableObjects.Count, Allocator.TempJob);

            for (int i = 0; i < cells.Length; i++)
            {
                cells[i]   = Field[i];
                indexes[i] = i;
                colors[i]  = _changeableObjects[i].Color;
            }

            var job = new CellChanger()
            {
                Cells   = cells,
                Indexes = indexes,
                Colors  = colors,
            };

            var jobHandler = job.Schedule(_changeableObjects.Count, 10);

            jobHandler.Complete();

            for (int i = 0; i < _changeableObjects.Count; i++)
            {
                var renderMesh = _entityManager.GetSharedComponentData <RenderMesh>(_changeableObjects[i].Entity);
                var mat        = new UnityEngine.Material(renderMesh.material);
                mat.SetColor("_Color", colors[i]);
                renderMesh.material = mat;

                _entityManager.SetSharedComponentData(_changeableObjects[i].Entity, renderMesh);
            }

            cells.Dispose();
            colors.Dispose();
            indexes.Dispose();
        }
示例#3
0
    void OnSceneGUI()
    {
        g = (GameScript)target;

        cA = Resources.FindObjectsOfTypeAll <CellChanger>();

        if (c == null)
        {
            c = cA[0];
        }

        SetToggleState();

        if (Event.current.type == EventType.MouseDown)
        {
            RaycastIntoScene();
        }
    }
示例#4
0
	//------------------------------------

	void Awake(){
		if (!instance)
			instance = this;
	}
示例#5
0
 static void Init()
 {
     CellChanger window = (CellChanger)GetWindow(typeof(CellChanger));
     window.Show();
 }