Exemplo n.º 1
0
 private void targetSurfaceChanged(ChangeEvent <UnityEngine.Object> e)
 {
     _targetObject = e.newValue as GameObject;
     _preDataBind.SetValueWithoutNotify(_preData = null);
     _spawnSObind.value = null;
     checkSRCdata();
 }
Exemplo n.º 2
0
    private void createPreDataClickListener()
    {
        PreDataSO  so         = ScriptableObject.CreateInstance <PreDataSO>();
        MeshFilter meshFilter = (target as DataCreation).targetSurface.GetComponent <MeshFilter>();

        so.trisAroundVertex = GeomPreprocessor.CreateTrisAroundVertex(meshFilter.sharedMesh);
        so.trilinks         = GeomPreprocessor.CreateTrilinks(meshFilter.sharedMesh);
        string assetFolderPath = "Resources/PreData";

        EditorUtil.PrepareFolder(assetFolderPath);
        AssetDatabase.CreateAsset(so, "Assets/" + assetFolderPath + "/" + meshFilter.transform.root.name + "_preData.asset");
        // AssetDatabase.SaveAssets();
    }
Exemplo n.º 3
0
    public override VisualElement CreateInspectorGUI()
    {
        _currentEditSpawnZone = -1;

        VisualElement customInspector = new VisualElement();

        _targetSurfaceBind = new ObjectField("Target Surface");
        _targetSurfaceBind.RegisterValueChangedCallback(targetSurfaceChanged);
        _targetSurfaceBind.objectType  = typeof(GameObject);
        _targetSurfaceBind.bindingPath = "targetSurface";
        customInspector.Add(_targetSurfaceBind);

        _preDataBind = new ObjectField("PreData");
        _preDataBind.RegisterValueChangedCallback(preDataChanged);
        _preDataBind.objectType  = typeof(PreDataSO);
        _preDataBind.bindingPath = "preData";
        customInspector.Add(_preDataBind);

        _spawnSObind = new ObjectField("Spawn Data");
        _spawnSObind.RegisterValueChangedCallback(spawnDataChanged);
        _spawnSObind.objectType  = typeof(SpawnSO);
        _spawnSObind.bindingPath = "spawnData";
        customInspector.Add(_spawnSObind);



        _spawnBox = new Box();
        customInspector.Add(_spawnBox);

        List <string>               items    = new List <string>();
        Func <VisualElement>        makeItem = () => new Label();
        Action <VisualElement, int> bindItem = (e, i) => (e as Label).text = items[i];
        const int itemHeight = ITEM_HEIGHT;

        _spawnZoneList = new ListView(items, itemHeight, makeItem, bindItem);
        _spawnZoneList.selectionType      = SelectionType.Single;
        _spawnZoneList.onSelectionChange += onItemChosenHandler;
        //_spawnZoneList.onSelectionChanged += objects => Debug.Log(objects);
        _spawnBox.Add(_spawnZoneList);

        Box arBtnBox = new Box();

        _spawnBox.Add(arBtnBox);
        arBtnBox.style.flexDirection = FlexDirection.Row;
        arBtnBox.style.alignContent  = Align.Center;

        _addSpawZoneBtn      = new Button(addSpawnZoneClickListener);
        _addSpawZoneBtn.text = "Add Spawn Zone";
        arBtnBox.Add(_addSpawZoneBtn);
        _removeSpawZoneBtn      = new Button(removeSpawnZoneClickListener);
        _removeSpawZoneBtn.text = "Remove Current Spawn Zone";
        arBtnBox.Add(_removeSpawZoneBtn);

        _spawnSetNameTf = new TextField("Spawn Set Name");
        _spawnBox.Add(_spawnSetNameTf);
        Button saveBtn = new Button(saveClickListener);

        saveBtn.text = "Save Spawns";
        _spawnBox.Add(saveBtn);

        SpawnCreation sc = target as SpawnCreation;

        _targetObject = sc.targetSurface;
        _preData      = sc.preData;
        _spawnSO      = sc.spawnData;
        checkSRCdata();

        return(customInspector);
    }
Exemplo n.º 4
0
 private void preDataChanged(ChangeEvent <UnityEngine.Object> e)
 {
     _preData = e.newValue as PreDataSO;
     checkSRCdata();
 }