Exemplo n.º 1
0
        private void Awake()
        {
            // Singleton
            if (Instance == null)
            {
                Msg.Log("GraphFactorySprout created");
                Instance = this;
                //DontDestroyOnLoad(gameObject);
            }
            else
            {
                Msg.LogWarning("GraphFactorySprout re-creation attempted, destroying the new one");
                Destroy(gameObject);
            }

            // Find graph factory
            GraphFactoryBtc gfb = GetComponent <GraphFactoryBtc>();

            if (gfb == null)
            {
                Msg.LogWarning("GraphFactorySprout could not find GraphFactory component - no nodes will sprout");
                IsAutoGrowActive = false;
            }
            else
            {
                _nodeFolder = gfb.ParentFolder;
            }
            Msg.Log("GraphFactorySprout is awake");
        }
Exemplo n.º 2
0
        private void Start()
        {
            UpdateSphereRadius();

            graphFactory  = FindObjectOfType <GraphFactoryBtc>();
            thisRigidbody = this.GetComponent <Rigidbody>();
        }
Exemplo n.º 3
0
        void Awake()
        {
            if (Instance == null)
            {
                Msg.Log("GraphFactoryBtc created");
                Instance    = this;
                _graphIndex = new Dictionary <string, GameObject>();

                //DontDestroyOnLoad(gameObject);
            }
            else
            {
                Msg.LogWarning("GraphFactoryBtc re-creation attempted, destroying the new one");
                Destroy(gameObject);
            }
        }
Exemplo n.º 4
0
        // Use this for initialization
        void Start()
        {
            // TODO this is inefficient and ugly
            _graphFactory = FindObjectOfType <GraphFactoryBtc>();
            _lineRenderer = gameObject.AddComponent <LineRenderer>();
            //lineRenderer = GetComponent<LineRenderer>();

            // Text label is mBTC and starts off invisible (to avoid having to fade it, it just appears after main fade in complete)
            LabelValuePrimary.text     = _valueMBtcPrimary.ToString("n2");
            LabelCanvasPrimary.enabled = false;
            if (_valueMBtcPrimary > 0f)
            {
                _isValueKnownPrimary = true;
            }

            // Color link according to type
            Color c;

            switch (_bitLinkTypePrimary)
            {
            case EdgeType.Input:
                c = GraphFactoryBtc.Instance.Visuals.ColLinkInput;
                break;

            case EdgeType.Output:
                c = GraphFactoryBtc.Instance.Visuals.ColLinkOutput;
                break;

            default:
                c = GraphFactoryBtc.Instance.Visuals.ColLinkDefault;
                break;
            }
            // Override when we are mixed
            if (_bitLinkTypeSecondary != null)
            {
                c = GraphFactoryBtc.Instance.Visuals.ColLinkMixed;
            }

            _startingColor = new Color(c.r, c.g, c.b, c.a);
            // set initial alpha to zero because we always fade in
            c.a = 0f;

            //draw line
            _lineRenderer.material = LinkMaterial;
            _lineRenderer.material.SetColor("_Color", c);
            _lineRenderer.startWidth    = GraphFactoryBtc.Instance.Visuals.WidthLinkDefault;
            _lineRenderer.endWidth      = GraphFactoryBtc.Instance.Visuals.WidthLinkDefault;
            _lineRenderer.positionCount = 2;
            _lineRenderer.sortingOrder  = -1;

            // send receive shadows
            _lineRenderer.receiveShadows    = false;
            _lineRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

            _lineRenderer.SetPosition(0, source.transform.position);
            _lineRenderer.SetPosition(1, target.transform.position);
            sourceRigidBody           = source.GetComponent <Rigidbody>();
            targetRigidBody           = target.GetComponent <Rigidbody>();
            intendedLinkLengthSquared = _graphFactory.LinkIntendedLinkLength * _graphFactory.LinkIntendedLinkLength;

            // arrow head
            //_arrowHeadRenderer.material.SetColor("_Color", c);
            // flip head for inputs - better done in update as we have to move it anyway, remember the arrow is attached to the parent game object
            // not to the line (renderer) and so since line renderer is redrawn each frame, so arrow must move too. If a true 3d line were used, could
            // attach arrowhead to the line truly and then not move it at all.

            // Added to ensure line width adjusted after line renderer created
            AdjustLineWidth();
            EnableAndPositionAllCanvases();

            // Fade in link
            StartCoroutine(FadeIn());

            // "Fade" for label, it just pops into existence after a delay
            if (GlobalData.Instance.IsGlobalLinkLabelActive)
            {
                Invoke("CanvasEnable", GraphFactoryBtc.Instance.Visuals.NodeFadeInTimeSeconds);
            }
            else
            {
                CanvasDisable();
            }
        }